Hi from past one month our firebase app started giving this error. "The script resource is behind a redirect, which is disallowed." We've registered the firebase-messaging-sw.js at the root of the server , and it opens in the browser as well. The same code works great in localhost but gives this error on a public domain (cloudflare dNS)
Already tried solutions mentioned here : Firebase: change the location of the service worker
Our current code :
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 contents :
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);
});```