I want to front an API on Cloud Run with Firebase Hosting on the /api prefix. So that an incoming request for /api/something is handled by the API /something handler. Seems simple but I can't figure it out, so I'm wondering if it's even possible with Firebase hosting.
First thing I've tried is:
"rewrites": [
{
"source": "/api",
"run": {
"serviceId": "my-api",
"region": "us-central1"
}
}
]
This correctly routes /api requests to the service root /, but calling /api/something just 404s.
Second attempt was using "source": "/api/**" or "regex": "/api(/.*)?",. This correctly receives requests like /api/something but routes it to the API root / instead of /something.
Ideally, I would like it to strip the /api prefix, or allow me to use the extracted regex group on the routed url.
Thanks.