after I build my Angular 17 project and upload it to hosting, when I press F5 on my page, it redirects to a 404 page. I couldn't solve this situation in Angular 17.
I can view the component I crossed out without any problems, but when I press F5 on that page, it sends me to the 404 page.
According to the resources I researched, I was supposed to use LocationStrategy and HashLocationStrategy, but I didn't know how to use it with Angular 17.
screenshots:
app.config.ts
With Angular 17, you can define your
LocationStrategy
in two ways...PathLocationStrategy
This is the Default strategy and relies on setting up the application's
<base href>
found inindex.html
HashLocationStrategy
This alternative strategy leverages the somewhat dated practice of adding a "#" to the URL for determining client updates and can be set by adding
withHashLocation()
to the app's provided router inapp.config.ts
You can find more on
LocationStrategy
via the Angular 17 Docs... https://angular.dev/guide/routing/common-router-tasks#locationstrategy-and-browser-url-styles