I’m creating a website using Angular Universal. It will have server-side rendering in order to make it indexable by search engines.
I already coded my 404 fallback route, it displays its component correctly, but it displays it with a HTTP 200 header code.
How can I force a specific header code ? I googled some queries, but everything I found seemed to be about reading an HTTP call’s status code, and nothing on how to write it to the browser.
2
Answers
Ok, I've finally succeeded.
I started over, and used Angular Universal Starter (CLI), with Patrick Michalina's scripts described here : https://github.com/DSpace/dspace-angular/issues/91#issuecomment-318547118
I followed the docs:
https://github.com/angular/universal/tree/master/modules/express-engine
Note, you bootstrap the app twice in server.ts, we need to provide the response every request.
Also we optionally inject the response into our app components, as the response will be NULL if the platform is the browser.
server.ts
some imports:
engine:
request handler:
routing:
component: