Handle 404 and 500 errors #667
Description
Note: for support questions, please use one of these channels: https://github.com/angular/universal/blob/master/CONTRIBUTING.md#question. This repository's issues are reserved for feature requests and bug reports. Also, Preboot has moved to https://github.com/angular/preboot - please make preboot-related issues there.
- I'm submitting a ...
- bug report
- feature request
- support request => Please do not submit support request here, see note at the top of this template.
- What modules are related to this Issue?
- express-engine
- grunt-prerender
- gulp-prerender
- hapi-engine
- universal-next
- universal
- webpack-prerender
-
Do you want to request a feature or report a bug?
Request a feature -
What is the current behavior?
There's currently no way I can find to make sure the server responds with an HTTP status code 404 when I need to.
Furthermore, when there's an error the server currently refuses the connection.
-
What is the expected behavior?
There should be a way to send responses with HTTP status 404.
Additionally, there should be a way to handle errors and send responses with HTTP status 500. -
What is the motivation / use case for changing the behavior?
When application logic determines there should be a 404 error (for instance, having a route for{ path: 'clients/:client-id' }
, doing an API request and finding the client ID requested doesn't exist) you should respond with a 404 page. Currently, you can handle this in your application and show a 404 page, but it'll be served with a 200 status code.
Additionally, there should be a way to handle any error and show the user a 500 error page, served with the correct status code.