We are trying to build a REST api using firebase functions. We want that format because we are a web services company who need to expose an api to our clients. People are mostly familiar with REST, therefore, REST.
Following the advice given here I have layered a custom domain in front of a firebase function. I did this by first forwarding my custom domain to the firebase domain via an A record,then setting up a rewrite for the hosting:
"hosting": {
"public": "public",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "/api/**",
"function": "api"
},
{
"source": "!/@(api)/**",
"destination": "/index.html"
}
]
},
Note that the api
function is mapped to anything going to /api/
. So far so good. Now I want to make a POST request with a body to mydomain.com/api/user
. Unfortunately, when doing so, I get a response Cannot GET /api/user
. It seems like firebase is converting the request into a GET before it reaches the function at api
. Does anyone know how to make POST requests to functions behind custom domains?