I have setup a ML model with basic API on Cloud Run and I want to call it from my a Firebase project.
They are both in the same project and I have tested Cloud Run independently:
- Deploying a NextJS site that I am deploying to Firebase, so if I run it locally as NextJS site (
next dev
) calling my Cloud Run function overhttps
it works fine:
async rewrites() {
return [
{
source: '/predict',
destination: 'https://<cloud-run-domain>.run.app/predict',
},
]
}
const response = await fetch('/predict', {
method: 'POST',
body: JSON.stringify(CallData)
})
However, when I deploy it to Firebase and setup rewrites in firebase.json. I do not get any invocations on Cloud Run side too.
"rewrites": [ {
"source": "**",
"run": {
"serviceId": "<cloud-run-service-name>",
"region": "europe-north1"
}
} ]
The POST calls returns 404
{
body: (...)
bodyUsed: true
headers: Headers {}
ok: false
redirected: false
status: 404
statusText: "Not Found"
type: "basic"
url: "http://localhost:5000/predict"
}
This example is form a local testing using firebase serve --only hosting
but returns the same on deployed version as well.
How do I debug Firebase rewrites and networking to figure out where the break down happens when calling the Cloud Run function?