1

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);
        });```

1 Answers1

0

Clicking on that link causes a redirection.

What if you try with the redirected url eg: https://prnt.sc/orot3j instead of http://prntscr.com/orot3j

Jonathan Irwin
  • 5,009
  • 2
  • 29
  • 48