Reputation: 237
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.
Upvotes: 7
Views: 7754
Reputation: 449
If you're using angular-cli-ghpages just change your deploy script to look like this:
"scripts": {
"deploy": "ng deploy --base-href=https://your-username.github.io/the-repositoryname/",
}
Your dist/index.html
should have the following:
<base href="https://your-username.github.io/the-repositoryname/">
Upvotes: 0
Reputation: 3443
For myself, I was trying to get my site working on a custom domain and kept getting 404 on publish. Here are the steps that worked for me getting a custom domain to work with angular app and GitHub Pages:
Let your DNS provider know about GH Pages:
Let your DNS provider know about your subdomain (i.e. www.example.com):
NOTE: Rest should be done in a new branch gh-pages
as outlined in angular docs
Go to your project local dir and execute command:
ng build --prod --output-dir docs --base-href "https://example.com"
Open the generated docs folder and make a copy of index.html and name it 404.html
git add .
and git commit
the changes then git push origin gh-pages
Go to your GitHub repo Settings > Pages
gh-pages
branch and /docs
Adding a custom domain name under the Pages setting will generate a CNAME file in the /docs
folder that can be pulled after entry to sync the repo.
Credit to this blog that got me most of the way there, but was missing some parts.
Upvotes: 1
Reputation: 6976
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/".
Upvotes: 10