securityerror 未能为范围

问题描述

我正在尝试为我的网站制作一个 PWA 应用程序,它在所有 PC 浏览器上都能正常工作 但是当我尝试在移动设备上打开该网站时,它给了我一个安全警告尽管该网站的 SSL 证书仍然有效

error uncaught (in promise) securityerror Failed to register a serviceworker for scope ('mydomain.com')with script ('mydomain.com/pwabuilder-sw.js')An SSL certificate error occurred when fetching the script

这是我用于 PWA 的清单

    "name": "Nistiman News","short_name": "Nistiman","scope":"/","description": "Nistiman News Magazine","icons": [
      {
        "src": "/icon2.png","sizes": "100x100","type": "image/png"
      },{
        "src": "/logo.png","sizes": "192x192","type": "image/png"
      }
    ],"start_url": "/","display": "fullscreen","theme_color": "#B12A34","background_color": "#B12A34"
  }

这是我的 serviceWorker


importScripts('https://storage.googleapis.com/workBox-cdn/releases/5.1.2/workBox-sw.js');

const CACHE = "pwabuilder-page";

// Todo: replace the following with the correct offline fallback page i.e.: const offlineFallbackPage = "offline.html";
const offlineFallbackPage = "offline.html";

self.addEventListener("message",(event) => {
  if (event.data && event.data.type === "SKIP_WAITING") {
    self.skipwaiting();
  }
});

self.addEventListener('install',async (event) => {
  event.waitUntil(
    caches.open(CACHE)
      .then((cache) => cache.add(offlineFallbackPage))
  );
});

if (workBox.navigationPreload.isSupported()) {
  workBox.navigationPreload.enable();
}

self.addEventListener('fetch',(event) => {
  if (event.request.mode === 'navigate') {
    event.respondWith((async () => {
      try {
        const preloadResp = await event.preloadResponse;

        if (preloadResp) {
          return preloadResp;
        }

        const networkResp = await fetch(event.request);
        return networkResp;
      } catch (error) {

        const cache = await caches.open(CACHE);
        const cachedResp = await cache.match(offlineFallbackPage);
        return cachedResp;
      }
    })());
  }
});

屏幕截图:

the site is working fine in all pc browsers

I install a dev browser on my mobile with inspect element to test the site and this is what I get

这是我的网站链接https://nistiman.net/

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)