Answer the question
In order to leave comments, you need to log in
How to generate 404 code in Angular Universal?
Good day! Can you please tell me how to specify the 404 response code for the node server in angular? The standard documentation only indicates how to specify it for a specific path '/api/*' but I would like the angular component to be able to indicate this response code to the server. Yes, and through Nginx along the way. Thank you!
Answer the question
In order to leave comments, you need to log in
First, (if the component is created, if not, create it) in the app-routing.module.ts file
{
path: '404', component: NotfoundComponent
},
{
path: '**', redirectTo: '/404'
}
1: import { RESPONSE } from '@nguniversal/express-engine/tokens';
2: constructor(@Optional() @Inject(RESPONSE) private response: any) { }
в ngOnInit() прописать
3: this.response.statusCode = 404;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question