Не могу сделать запрос из firebase hosting
Развернул функцию в cloud.functions:
const cors = require('cors')({origin: true});
const functions = require('firebase-functions');
exports.hello = functions.https.onRequest((req, res) => {
cors(req, res, () => {
console.log('Привет мир!');
// Send Response
res.status(200).send('Привет мир!');
});
});
в firebase.json добавил обращение к функции hello, при запросе по адресу mysite.web.app/hello:
{
"hosting": {
"public": "build/web",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"headers": [ {
"source" : "*",
"headers" : [ {
"key" : "Access-Control-Allow-Origin",
"value" : "*"
} ]
}],
"rewrites": [
{
"source": "/hello",
"function": "hello"
},
{
"source": "/bigben/bigben",
"function": "bigben"
},
{
"source": "**",
"destination": "/index.html"
}
]
}
}
При запросе все равно выходит ошибка:
Access to fetch at 'https://accounts.google.com/ServiceLogin?service=ah&passive=true&continue=https://uc.appengine.google.com/_ah/conflogin%3Fcontinue%3Dhttps://us-central1-mysite.cloudfunctions.net/hello/hello' (redirected from 'https://mysite.web.app/hello') from origin 'https://mysite.web.app' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.