404将Angular 6应用程序部署到github页面时 [英] 404 when Deploying Angular 6 app to github pages

查看:86
本文介绍了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/".

这篇关于404将Angular 6应用程序部署到github页面时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆