Deployed angular 4 app has broken links

I have deployed my app using "ng build --prod" on my nginx server. I can access the home page but when I click any of the links it cant find the pages. What am i missing?

Watch your network requests using your browser's developer tools (e.g. Chrome's Developer Tools / Network tab), and see what URLs are being requested vs. what they should actually be.

It's likely that you developed your app using the root context (your index.html page was coming from http://localhost:4200/index.html), and that now under nginx, you have a different context for the app (e.g.

If that's the case, your index.html will be resolving correctly, but all other requests may be going to, for example, instead of

To fix that, you'd have to add a tag to the head of your index.html to indicate the proper base url.

0 Comment



Captcha image