I have a problem that is frustrating me.

I can't seem to serve 404 status with angular 5.

Steps taken:

In my server.ts, I imported

```js
const { AppServerModuleNgFactory, LAZY_MODULE_MAP } = require(`./dist-server/main.${hash}.bundle`);
import { ngExpressEngine } from '@nguniversal/express-engine';
import { REQUEST, RESPONSE } from '@nguniversal/express-engine/tokens';
```

And Added

```js
app.engine('html', (_, options, callback) =>
    ngExpressEngine({
        bootstrap: AppServerModuleNgFactory,
        providers: [
            provideModuleMap(LAZY_MODULE_MAP),
            {
                provide: REQUEST,
                useValue: options.req,
            },
            {
                provide: RESPONSE,
                useValue: options.req.res,
            },
        ]
    })(_, options, callback)
);
```

In my actual not-found component,

```js
import { Component, Inject, Injector, OnInit, PLATFORM_ID } from '@angular/core';
import { isPlatformBrowser } from '@angular/common';
import { RESPONSE } from '@nguniversal/express-engine/tokens';
import { Response } from 'express';

@Component({
 selector: 'not-found',
 templateUrl: './not-found.component.html',
 styleUrls: ['./not-found.component.scss']
})

export class NotFoundComponent implements OnInit {
 constructor(
  @Inject(PLATFORM_ID) private platformId: Object,
  @Inject(Injector) private injector: Injector
 ) {}

 ngOnInit() {
   const response = this.injector.get(RESPONSE) as Response;
   response.status(404);
  }
 }
}
```

First of all I don't understand why I'm getting this error:
[![enter image description here](https://i.stack.imgur.com/PdoCq.png)](https://i.stack.imgur.com/PdoCq.png)

I'm running this on localhost and I'm following this implementation:
<https://blog.thecodecampus.de/angular-universal-handle-404-set-status-codes/>

In the comments section we're told to replace @Optional() @Inject(RESPONSE) private response: Response) with @Inject(Injector) private injector: Injector.