Answers for "firebase hosting rewrite function You need to enable JavaScript to run this app."

0

firebase hosting rewrite function You need to enable JavaScript to run this app.

The issue could be due to the order of your firebase.json rewrites. If 
{
  "source": "**",
  "destination": "/index.html"
}
is at the top of your rewrites then everything will match the "**" wildcard first, which is not what we want.

Instead, put the api (or whatever) rewrites first and put "**" last. E.g:
"rewrites": [
  {
    "source": "/api/**",
    "function": "api"
  },
  {
    "source": "**",
    "destination": "/index.html"
  }
]
This way the "/api/**" route is caught first and then everything else falls through. (Obvious in hindsight...)

Hope this helps save someone else a few hours!
Posted by: Guest on April-21-2022

Code answers related to "firebase hosting rewrite function You need to enable JavaScript to run this app."

Browse Popular Code Answers by Language