refreshing the page results in 401 error- Angular 8

Viewed 316

when I hithttp://localhost:4200 or http://localhost:4200/forgotPasswordEmail on my local environment, it works correctly.

Opening the index-page on my production environment and clicking a link to go to another page, also works. However, when I refresh the page or go directly to http://<prod url>/forgotPasswordEmail, it doesn't work and then I get the following error:

error page

I guess that when I hit the URL, it's trying to search the rest API code for forgotPasswordEmail and it's not able to find the value so it's returning 401 but locally it's working fine.

2 Answers

In your server config, you need to render index.html every route that is not a static file or folder. Routing should be handled by the angular application, not the server.

I will achieve this through

security.basic.enable: false
security.ignored=/**
Related