问题
My application works fine when served locally. I have compiled the build with no errors.
Site link is here - https://evilernie44.github.io/users/index.html
When I try to load the site via the github page, I get a 404 on my get requests.
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.
回答1:
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/".
来源:https://stackoverflow.com/questions/54408517/404-when-deploying-angular-6-app-to-github-pages