Develop a small application with Angular. When doing the ng build --prod, I pass to my server the /dist folder generated with the --base-href /test/ (the /test/ folder is where I have my application) and everything works very well running in the browser www-mysite.com /test, BUT if I update the browser, the application stops working.
-
1What do you mean by "update the browser"?user184994– user1849942018-04-20 16:45:38 +00:00Commented Apr 20, 2018 at 16:45
-
I mean refresh the websidesioesi– sioesi2018-04-20 16:56:26 +00:00Commented Apr 20, 2018 at 16:56
-
set a default routerShohel– Shohel2018-04-20 16:57:39 +00:00Commented Apr 20, 2018 at 16:57
-
@Shohel how set?sioesi– sioesi2018-04-20 17:02:06 +00:00Commented Apr 20, 2018 at 17:02
-
I have added a link in my answer which will help you set them. what type of server you are using ?ashfaq.p– ashfaq.p2018-04-20 17:02:41 +00:00Commented Apr 20, 2018 at 17:02
|
Show 2 more comments
1 Answer
you will have to use some kind of redirect_mode (depending on your server) to redirect all requests to index.html. This is needed for all single page applications.
If you will refresh on www.mysite.com, it will work. It will break when you refresh on /test route. This is because your routes are defined on client side and server is unaware of them.
Read more about how to configure this here: https://medium.com/@pshrmn/single-page-applications-and-the-server-32a23d67936