0

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.

7
  • 1
    What do you mean by "update the browser"? Commented Apr 20, 2018 at 16:45
  • I mean refresh the webside Commented Apr 20, 2018 at 16:56
  • set a default router Commented Apr 20, 2018 at 16:57
  • @Shohel how set? Commented 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 ? Commented Apr 20, 2018 at 17:02

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for your help and excuse the little knowledge: D
glad to help you

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.