Reputation: 1227
While attempting to get CORS working with Cloud Functions for Firebase, I tried to follow the official example here: https://github.com/firebase/functions-samples/tree/master/authorized-https-endpoint
However, even following the tutorial instructions as exactly as possible, I still get this error in the console:
Upvotes: 4
Views: 6326
Reputation: 1227
I never got CORS working, but the workaround I found was to use hosting redirects for the functions. That way, HTTP function calls are not cross site at all.
https://firebase.google.com/docs/hosting/functions (See "Direct Hosting requests to your function")
{
"hosting": {
"public": "public",
// Add the following rewrites section *within* "hosting"
"rewrites": [ {
"source": "/api/bigben", "function": "bigben"
} ]
}
}
Note: I have to define a redirect for every endpoint. Is there a way to have general rewrites? e.g.
"source": "/api/*", "function": "*"
Upvotes: 1
Reputation: 1812
Try following this ?
Hope that helps!
Upvotes: 0