From f08603c30acec4c4f3b0db981fb035323e323582 Mon Sep 17 00:00:00 2001 From: thuhole Date: Sat, 20 Jun 2020 00:11:24 +0800 Subject: [PATCH] re-add CDN & fix registerServerWorker --- package.json | 2 +- src/registerServiceWorker.js | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 52a52e5..4b0864b 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "deploy": "gh-pages -d build -m $(TZ=Asia/Shanghai date +\"%y%m%d%H%M%S\")", "eject": "react-scripts eject" }, - "homepage": ".", + "homepage": "https://://cdn.jsdelivr.net/gh/thuhole/webhole@gh-pages", "browserslist": { "production": [ ">0.2%", diff --git a/src/registerServiceWorker.js b/src/registerServiceWorker.js index a3e6c0c..cd50aac 100644 --- a/src/registerServiceWorker.js +++ b/src/registerServiceWorker.js @@ -21,13 +21,13 @@ const isLocalhost = Boolean( export default function register() { if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) { // The URL constructor is available in all browsers that support SW. - const publicUrl = new URL(process.env.PUBLIC_URL, window.location); - if (publicUrl.origin !== window.location.origin) { - // Our service worker won't work if PUBLIC_URL is on a different origin - // from what our page is served on. This might happen if a CDN is used to - // serve assets; see https://github.com/facebookincubator/create-react-app/issues/2374 - return; - } + // const publicUrl = new URL(process.env.PUBLIC_URL, window.location); + // if (publicUrl.origin !== window.location.origin) { + // // Our service worker won't work if PUBLIC_URL is on a different origin + // // from what our page is served on. This might happen if a CDN is used to + // // serve assets; see https://github.com/facebookincubator/create-react-app/issues/2374 + // return; + // } window.addEventListener('load', () => { const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;