I am setting up a redirect(rewrite) with my firebase hosting so that I can call an api that is running from google cloud run here.
I have tried changing the rewrite string from "/api/**"
(should catch all things to page.com/api/** and send that to the function). deleted the index.html and swapped to "**"
to capture ALL paths including index. Nothing has worked so far.
My hosting firebase.json is setup like so, is there something wrong with this?
{
"hosting": {
"public": "dist/public",
"ignore": ["firebase.json", "**.*", "**/node_modules/**"],
"rewrites": [
{
"source": "**",
"run": {
"serviceId": "next-js-base-api",
"region": "us-central1"
}
}
]
}
}
I also tried with normal redirects to another page, this does not work, what determines when the firebase.json settings begin to propagate and work?
I tried running the hosting emulator and with a modified rewrite "source": "/api/**"
which had the following results. Navigating to /api returns non crash (doesn't redirect) with output in browser of cannot GET /api
navigating to api/wkapi (a sub directory that is caught by the api endpoint) returns an unexpected error
in the browser and
Error: Unable to find a matching rewriter for {"source":"/api/**","run":{"serviceId":"next-js-base-api","region":"us-central1"}}
in the console.
Make sure to update to the latest version of your Firebase CLI by running:
npm install -g firebase-tools@latest
This will enable you to rewrite to cloud run instances as you are trying to do.