reactjs - 脚本资源位于重定向后面,这是不允许的。firebase 云消息传递 firebase-messaing-sw.js
问题描述
这实际上是该主题的副本,因为没有人对此进行回复:脚本资源位于重定向后面,这是不允许的。firebase 云消息传递
嗨,从过去一个月开始,我们的 Firebase 应用程序开始出现此错误。“脚本资源位于重定向后面,这是不允许的。” 我们已经在服务器的根目录注册了 firebase-messaging-sw.js,它也在浏览器中打开。相同的代码在 localhost 中运行良好,但在公共域(cloudflare dNS)上出现此错误
已经尝试过这里提到的解决方案:Firebase:更改服务人员的位置
我们当前的代码:
messaging = firebase.messaging();
$this.setState({messaging});
messaging.useServiceWorker(registration);
messaging.requestPermission().then(function() {
$this.setState({permission:true});
messaging.getToken().then(function(currentToken) {
$this.setState({fcmtoken:currentToken});
resolve(currentToken);
});
});
});
firebase-messaging-sw.js 内容:
``` importScripts("https://www.gstatic.com/firebasejs/5.3.0/firebase-messaging.js");
var config = {
apiKey: "AIzxxxxxxxxxxxxxx0",
authDomain: "noxxxxions-7xxxd.firebaseapp.com",
databaseURL: "https://notifications-76xxxxd.firebaseio.com",
projectId: "nxxxxxxxxxxd",
storageBucket: "notifixxxxxx.appspot.com",
messagingSenderId: "90000000000"
};
firebase.initializeApp(config);
var messaging = firebase.messaging();
messaging.setBackgroundMessageHandler(function(payload) {
var notificationTitle = "Background Message Title";
var notificationOptions = {
body: "Background Message body.",
icon: "/firebase-logo.png"
};
return self.registration.showNotification(notificationTitle,
notificationOptions);
});```
解决方案
推荐阅读
- wordpress - 使用带有高级自定义字段库字段的指标填充 bootstrap4 轮播
- python - 具有并行后端的 sklearn 将日志/输出发送到控制台而不是笔记本单元输出
- sse - _mm_movemask_ps() 的最快倒数是多少?
- angular - '"==="' 类型的参数不能分配给 'WhereFilterOp' 类型的参数
- ffmpeg - FFmpeg 添加自己的元数据 - 编码器:Lavf58.20.100
- javascript - 修复导航滚动太远并覆盖内容顶部
- bash - 如何在 WSL 上运行 bash 脚本
- vue.js - 在组件之间使用 .once
- json - 在 Dart 中将逗号分隔的字符串转换/反序列化为对象
- c# - 如何在 xamarin 中为 whatsapp 制作自动回复应用程序