GitHub Pages shows me 404 when I use automatic redirection to the login path or try to directly access that path other than the base path in Angular.
I created an application in Angular that automatically redirects to "/auth/login" when it detects that the session has not been logged in.
So the problem I have is if I directly access the URL "user.github.io/example-app" the application works fine and perfect, but if I directly access the URL "user.github.io/example-app/auth/login" (or any path other than the parent) throws me the 404 GitHub Pages.
Even I am using PWA and when installing the app on my Android device it directly throws the 404 of GitHub Pages.
Note:
I have also noticed that if I use Lighthouse and do a test using http-server, it also throws a 404 when executing the test.
Using http-server I can install the application on Windows and this does show me the application, not the 404 that happened to me with GitHub Pages.
tl;dr Use HashLocationStrategy or Scully .
Angular, by default, uses the History API for routing.
This system allows the JavaScript to tell the browser:
I have manipulated the DOM so the user is effectively looking at a new page. If you went to this URL then the server would send you this page .
Unfortunately, Angular does nothing to make that possibly by default. There are three approaches that are used to get the server to play ball.
Alternatively, keep having a single HTML document, ditch the history API, and replace it with a URL scheme that is based on the premise that you have only a single HTML document. Use the HashLocationStrategy ).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.