Router LocationStrategy not a "local URL", baseHref results in 404
See original GitHub issueDescription
Doc is misleading ‘[LocationStrategy and browser URL styles ]’(https://angular.io/guide/router#locationstrategy-and-browser-url-styles) says:
“this is a strictly local URL the browser won’t send this URL to the server and will not reload the page” and “a technique that changes a browser’s location and history without triggering a server page request”
🔬 Minimal Reproduction
https://mysite.com/basehref/app/route/featuremoduleroute shows 404
The angular browser navigation does trigger server a page request.
What’s the affected URL?**
private, can supply on request
Reproduction Steps**
I have a azure static website and am hosting the angular app in a sub-folder called /cp/ To build the angular app:
ng build --prod --output-path dist/cp/ --base-href /cp/
which is fine for viewing the root url, but as soon as I navigate to feature module child route, the server redirects my page to 404 as that URL route does not exist.
I have had to resort to ‘useHash:true’ on the router extraOptions.
Expected vs Actual Behavior**
Docs should say: Some applications will be on shared infrastructure and end up being hosted in a sub-folder. A hosted server’s routing re-write rules should redirect all traffic to your application, e.g. /baseHref/* to /baseHref/ If you do not have access to the server routing definition, even on modern browsers, use a baseHref during build and set ‘useHash:true’ on the app router extraOptions as detailed in the HashLocationStrategy docs.
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (3 by maintainers)
Top GitHub Comments
@OzBob - Again, the statement you’re pointing to is referring to navigations through the Angular router. Deep links go to the server because there’s no page loaded. My opinion is that it’s not misleading at all but could potentially use clarification.
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.