In angular 7 when using <base href="/">
and ng build --prod
on terminal , don't works on production server. If I use <base href="./">
Works but when refresh it loose the path and I get 404
Asked
Active
Viewed 2,516 times
-1

Abhishek
- 1,742
- 2
- 14
- 25

Pedro Ferreira
- 9
- 1
- 4
-
you shouldnt use `
` in production, you should change it to your actual url/host name – mast3rd3mon Apr 05 '19 at 10:59 -
I tried that. It opens and I can navigate with the menu. But when I refresh the page on some url that isn't the root I get 404 – Pedro Ferreira Apr 05 '19 at 11:10
-
then it sounds like an issue with your host – mast3rd3mon Apr 05 '19 at 11:18
1 Answers
0
I found a solution here: Angular deployment - 404 on page Refresh
with -> import {LocationStrategy, HashLocationStrategy} from '@angular/common';
using >ng build --prod --base-href=/my/app/
It adds an # in the url but works fine and I can refresh the page.
Thanks

Pedro Ferreira
- 9
- 1
- 4