The script resource is behind a redirect, which is disallowed. firebase cloud messaging

て烟熏妆下的殇ゞ 提交于 2020-01-15 11:46:19

问题


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:


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



来源:https://stackoverflow.com/questions/57464258/the-script-resource-is-behind-a-redirect-which-is-disallowed-firebase-cloud-me

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!