firebase function has been blocked by CORS policy
I experienced this issue while following a tutorial by The Net Ninja - Firebase Functions
function/index.js
1exports.sayHello = functions.https.onCall((data, context) => {
2 return `Yo dudes and dudettes`;
3})
DEPLOY this to Google .
And then in our button action ( fired by javascript )
1const sayHello = firebase.functions().httpsCallable('sayHello');
2 sayHello().then(result => {
3 console.log(result.data);
4 });
I’d then get a CORS issue firebase function has been blocked by CORS policy
The following call to assign the region worked for me in the Google Function itself.
exports.sayHello = functions.region('us-central1').https.onCall((data, context) => {
return `Yo dudes and dudettes`;
})
No comments:
Post a Comment