Routing setting for 404 on NodeJS

Hey Everyone,

I am not able to redirect users to a 404 error page when they type in a wrong url.

I have seen that for php projects you can edit the .htaccess file, however I am not sure how to do that for a nodeJS project.

Anyone has any suggestions?

2 Likes

You can add a custom 404 page by adding a route for the path * as a last route in the routing manager

2 Likes

Done. Thank you George :relaxed:

I am building a single page app and have logic to return to the home page when path is not matched. What I would like to do is clear the url without page reloading, is this possible?

Please check Creating Custom Error Pages in NodeJS