相关疑难解决方法(0)

由于CORS问题,firebase托管阻止脚本

我使用firebase托管来托管几个脚本并尝试从其他站点访问它们.由于CORS问题,它自然会被阻止.根据我对其他论坛帖子等的研究,我修改了firebase.json,如下所示

{
  "hosting": {
    "public": "public",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "headers": [ {
    "source" : "**",
    "headers" : [ {
      "key" : "Access-Control-Allow-Origin",
      "value" : "*"
    } ]
  }]
}
}
Run Code Online (Sandbox Code Playgroud)

这实际上允许任何URL访问此处托管的资源.但是,在尝试运行我的网站时,我仍然会在下面看到

        Access to XMLHttpRequest at 'https://oracle-bot-sdk.firebaseapp.com//loader.json' 
    from origin 'https://insurance-bot.moblize.it' has been blocked by CORS policy: 
No 'Access-Control-Allow-Origin' header is present on the requested resource.
Run Code Online (Sandbox Code Playgroud)

还需要什么?

cors firebase firebase-hosting

16
推荐指数
3
解决办法
6463
查看次数

尝试通过Firebase Cloud Functions(Android)发送通知后出现错误

我是Firebase和Node.js的新手。我正在尝试使用Firebase Cloud Functions将通知从一台设备发送到另一台设备。

这是发送通知的node.js代码:

var functions = require('firebase-functions');
var admin = require('firebase-admin');

admin.initializeApp(functions.config().firebase);

exports.sendNotification = functions.database.ref('/sendNotification/{notificationId}')
        .onWrite(event => {

        var regToken="fYRweeL8cic:APA91bH6Q_gyKKrLL...";

        // Grab the current value of what was written to the Realtime Database.
        var eventSnapshot = event.data;

        var payload = {
            data: {
                title: eventSnapshot.child("title").val()
            }
        };

        // Set the message as high priority and have it expire after 24 hours.
        var options = {
        priority: "high",
        timeToLive: 60 * 60 * 24
        };


    admin.messaging().sendToDevice(regToken,payload,options)
    .then(function(response){
        console.log("Successfully sent message: …
Run Code Online (Sandbox Code Playgroud)

node.js firebase google-cloud-functions firebase-cloud-messaging

5
推荐指数
1
解决办法
3183
查看次数

Firebase的云功能 - 即使我正在为firebase-admin功能发出出站http请求,也会出现网络错误

我有一个函数文件,我目前正在尝试做的就是访问Firebase auth()功能,根据电子邮件检查用户是否存在,然后获取他们的uid.

我有一个Angular 2应用程序,我在其中运行一个http请求来调用该函数,但是每当我尝试运行它时,我都会收到此错误:

Billing account not configured. External network is not accessible and quotas are severely limited. Configure billing account to remove these restrictions
Run Code Online (Sandbox Code Playgroud)

这是我的代码:

const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);

/**
 *  Function to get a user by email
 */
exports.getUserByEmail = functions.https.onRequest((req, res) => {
  console.log('req', req);
  return admin.auth().getUserByEmail(req.query.email);
});
Run Code Online (Sandbox Code Playgroud)

这种类型的东西不允许在Spark计划中吗?我仍然在开发我的应用程序,这是我现在唯一需要工作的东西,我宁愿不必立即开始付费只是为了使用这个小功能.有什么我能做的吗?

提前致谢!

firebase google-cloud-functions

4
推荐指数
1
解决办法
5702
查看次数