I have a Angular project where routing works in localhost, but when I deploy my project to Firebase hosting only the base-url works. Here is my routing: Example https://baseurl/jegharaldrigkategori does not work in Firbase hosting. It says "Page not found"
const routes: Routes = [
{
path: '',
redirectTo: 'home',
pathMatch: 'full'
},
{
path: 'home',
component: HomeComponent
},
{
path: 'jegharaldrigkategori',
component: JegharaldrigkategoriComponent
},
{
path: 'jegharaldrig',
component: JegharaldrigComponent
},
{
path: 'udfordring',
component: UdfordringComponent
},
{
path: 'terning',
component: TerningComponent
},
{
path: 'overunder',
component: OverunderComponent
}
];
When hosting on firebase you must remember to redirect all calls to index.html
.
The hosting portion of your firebase.json
should include "rewrites", here's an example :
"hosting": {
"public": "public",
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
},