问题
I made a simple Angular 5 cover to say that I'm still constructing this website.
ng serve
works fine locally, but now I wanted to host this on my schools website here and I get all these 404 resources not found and all I did was copy whats in the dist/ folder after running ng build --prod
to the www/ folder on the webserver.
It's angular 5 with this cli version:
"@angular/cli": "~1.7.1",
"@angular/compiler-cli": "^5.2.0",
I tried to push another one to github-pages and this has the same problem githubpages the repo is repo but it's almost an empty repo.
回答1:
You need to add --base-href
parameter when you build your application, like this:
ng build --prod --base-href /~320255eg/
Where /~320255eg/
represents the path to your application.
来源:https://stackoverflow.com/questions/49294514/angular-5-error-404-when-copying-dist-to-webserver