Search code examples
firebasefirebase-hosting

Firebase hosting: Rewrite to function not working


My firebase.json:

{
  "hosting": [
    {
      "target": "dev",
      "public": "public",
      "ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
      "rewrites": [
        {
          "source": "**",
          "function": "ssr",
          "region": "europe-west1"
        }
      ]
    }
  ],
}

I'm trying to rewrite any traffic to my ssr function. Whenever I try to access my website, I get a 404 with the messages Error: Page not found and The requested URL was not found on this server.

I have successfully deployed the ssr function. The function works if I access its URL directly. But for some reason, firebase rewriting is just not working.

What am I missing?


Solution

  • I was deploying my functions and hosting separately, e.g. firebase deploy --only functions. When I tried deploying them simultaneously, i.e. by just running firebase deploy it worked.