4

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
  }
];
1
  • What does your firebase.json config look like? Is it setup to serve index.html for all paths? Commented Mar 22, 2020 at 20:48

1 Answer 1

11

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"
      }
    ]
  },
Sign up to request clarification or add additional context in comments.

2 Comments

I got the same error. I did this in firebase.json & firebase 404 page is not showing up. But now my theme's 404 error page is opening. But in my route there is a valid URL. Any solution for this?
Can you rephrase @Sayandeep?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.