将 Angular 6 应用程序部署到 github 页面时出现 404 [英] 404 when Deploying Angular 6 app to github pages
问题描述
我的应用程序在本地提供时运行良好.我已经编译了没有错误的构建.
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/".
这篇关于将 Angular 6 应用程序部署到 github 页面时出现 404的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!