Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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!
 
PREVIOUS NEXT
Tagged: #firebase #hosting #rewrite #function #You #enable #JavaScript #run
ADD COMMENT
Topic
Name
8+7 =