1

This is actually a duplicate of this topic since no-one replying on this : The script resource is behind a redirect, which is disallowed. firebase cloud messaging

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)

https://prnt.sc/orot3j

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);
    });```
  • Possible duplicate of [The script resource is behind a redirect, which is disallowed. firebase cloud messaging](https://stackoverflow.com/questions/57464258/the-script-resource-is-behind-a-redirect-which-is-disallowed-firebase-cloud-me) – FaizAzhar Aug 22 '19 at 15:35
  • yes its the same since no one replying on this : https://stackoverflow.com/questions/57464258/the-script-resource-is-behind-a-redirect-which-is-disallowed-firebase-cloud-me . i created a new topic.Any solutions ? – Obitouzomaki Aug 23 '19 at 06:18

0 Answers0