Angular 5 error 404 when copying dist to webserver

我怕爱的太早我们不能终老 提交于 2019-12-08 07:02:39

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!