404将Angular 6应用程序部署到github页面时

问题描述:

我的应用程序在本地提供服务时可以正常工作.我已经编译了构建,没有错误.

My application works fine when served locally. I have compiled the build with no errors.

站点链接在此处- https://evilernie44.github.io/users/index.html

当我尝试通过github页面加载网站时,我的get请求得到404.

When I try to load the site via the github page, I get a 404 on my get requests.

我尝试过添加404.html,然后按照angular docs的建议将index.html的内容复制到它,但是我似乎仍然无法使它正常工作.

I have tried adding a 404.html and then copying the contents of index.html to it as suggested by angular docs but I still cannot seem to get it to work.

我对下一步的工作一无所知,有没有人有任何建议.

I am at a loss as regards to what to do next, does anyone have any suggestions.

如果Angular应用程序的根目录位于路径下,而不位于域的根目录下,则.如果应用程序是使用Angular CLI构建的,则可以使用.

If the root of an Angular application is under a path and not at the root of the domain, then the <base> tag needs to be set to match the path. In your case you need to set <base href="/users/">. If the application is built with the Angular CLI, then the <base> tag can be set with ng build --baseHref="/users/".