This is because when you perform a full reboot, you always send a request to the server with the current URL. Since Angular is not loaded yet, it cannot process the route, and the server does not know anything about which routes exist in Angular and not
Without html5mode Angular, fragmented URLs like www.example.com/#/page . # was originally used to bind links, so by convention, the fragmented part of the URL is completely ignored by the server. For the server, this request will be the same as only www.example.com/ , which is probably located where index.html is located. Therefore, reloading your page in this case will receive your index.html, which will load Angular, which in turn will process the fragmented part of the URL (# / page).
With html5mode, however, the snippet is hidden and the URL looks like a regular url, www.example.com/page . But when you reload the page, the server does not receive the fragment, so it tries to find everything that is served under the / page, which is probably nothing. Giving you 404, Angular cannot load, as index.html is not loaded and you have a broken page.
The usual way to fix this is for the server to serve index.html under all URLs that don't match the static resource (or the pattern of one). Therefore, if you ask to say an image, it will find it and return it normally, but if you request / the page (and it does not exist as a static asset), then it returns index.html. Then Angular will start, read the URL and activate the correct route.
I just did it in nginx, so I donโt know how Tomcat will do it, but the principle should be the same.
source share