Problem with deploy the build folder on nginx
clairekh opened this issue · comments
<Please explain the issue overview here, short but concise and to-the-point>
I have problem with deploy the build folder (generated by npm run build
) on nginx.
Application url: http://localhost/angular2-starter/
I have errors:
"NetworkError: 404 Not Found - http://localhost/assets/bundle-e5a31ad078.css"
"NetworkError: 404 Not Found - http://localhost/assets/lib-e417833ab8.js"
"NetworkError: 404 Not Found - http://localhost/assets/app-2bb2880752.js"
Issue Description
After that I edited base href in **index.html** to `` and did new deploy. Now application is starting. But if I want go to second level page directly like [Todolist](http://localhost/angular2-starter/todolist), I have error: `"NetworkError: 404 Not Found - http://localhost/angular2-starter/todolist"` ## Reproducables<Please explain the way to reproduce your issue, or even better with Plunker link>
It is produced after deploy the build folder on web server.
The same situation in demo version. Please, go here.
Information
Operating System | Ubuntu |
Node version | 6.6.0 |
NPM Version | 3.10.3 |
Environment | Chrome / Mozilla Firefox |
My demo used Github page which currently don't support redirection (unlike Firebase hosting), I'll consider moving soon.
You need to configure your nginx/any web server to redirect all to index.html and Angular router will handle the rest.
This may help https://stackoverflow.com/questions/7027636/nginx-send-all-requests-to-a-single-html-page
So this is not the starter issue, but the server/hosting issue.
In any case, you'd make it working without redirection, you need to change the routing strategy
https://angular.io/docs/ts/latest/api/common/index/PathLocationStrategy-class.html (default)
https://angular.io/docs/ts/latest/api/common/index/HashLocationStrategy-class.html