|
@@ -9,22 +9,23 @@
|
|
|
|
|
|
// To learn more about the benefits of this model and instructions on how to
|
|
|
// opt-in, read https://cra.link/PWA
|
|
|
-const isLocalhost = Boolean(
|
|
|
- window.location.hostname === 'localhost' ||
|
|
|
- window.location.hostname === '192.168.0.109' ||
|
|
|
- // [::1] is the IPv6 localhost address.
|
|
|
- window.location.hostname === '[::1]' ||
|
|
|
- // 127.0.0.0/8 are considered localhost for IPv4.
|
|
|
- window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/)
|
|
|
- );
|
|
|
+const isLocalhost = true
|
|
|
+
|
|
|
+// Boolean(
|
|
|
+// window.location.hostname === 'localhost' ||
|
|
|
+// window.location.hostname === '192.168.0.109' ||
|
|
|
+// // [::1] is the IPv6 localhost address.
|
|
|
+// window.location.hostname === '[::1]' ||
|
|
|
+// // 127.0.0.0/8 are considered localhost for IPv4.
|
|
|
+// window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/)
|
|
|
+// );
|
|
|
|
|
|
export function register(config) {
|
|
|
- // console.log('registering..', navigator)
|
|
|
if ('serviceWorker' in navigator) {
|
|
|
- //console.log('registering..', navigator)
|
|
|
-
|
|
|
+ console.log('registering..')
|
|
|
// The URL constructor is available in all browsers that support SW.
|
|
|
const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href);
|
|
|
+ console.log(publicUrl)
|
|
|
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
|
|
@@ -35,22 +36,7 @@ const isLocalhost = Boolean(
|
|
|
window.addEventListener('load', () => {
|
|
|
const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;
|
|
|
console.log(swUrl, config)
|
|
|
- if (isLocalhost) {
|
|
|
- // This is running on localhost. Let's check if a service worker still exists or not.
|
|
|
- checkValidServiceWorker(swUrl, config);
|
|
|
-
|
|
|
- // Add some additional logging to localhost, pointing developers to the
|
|
|
- // service worker/PWA documentation.
|
|
|
- navigator.serviceWorker.ready.then(() => {
|
|
|
- console.log(
|
|
|
- 'This web app is being served cache-first by a service ' +
|
|
|
- 'worker. To learn more, visit https://cra.link/PWA'
|
|
|
- );
|
|
|
- });
|
|
|
- } else {
|
|
|
- // Is not localhost. Just register service worker
|
|
|
- registerValidSW(swUrl, config);
|
|
|
- }
|
|
|
+ registerValidSW(swUrl, config);
|
|
|
});
|
|
|
}
|
|
|
}
|
|
@@ -59,6 +45,7 @@ const isLocalhost = Boolean(
|
|
|
navigator.serviceWorker
|
|
|
.register(swUrl)
|
|
|
.then((registration) => {
|
|
|
+ console.log('registration...')
|
|
|
registration.onupdatefound = () => {
|
|
|
const installingWorker = registration.installing;
|
|
|
if (installingWorker == null) {
|
|
@@ -127,14 +114,14 @@ const isLocalhost = Boolean(
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- export function unregister() {
|
|
|
- if ('serviceWorker' in navigator) {
|
|
|
- navigator.serviceWorker.ready
|
|
|
- .then((registration) => {
|
|
|
- registration.unregister();
|
|
|
- })
|
|
|
- .catch((error) => {
|
|
|
- console.error(error.message);
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
+ // export function unregister() {
|
|
|
+ // if ('serviceWorker' in navigator) {
|
|
|
+ // navigator.serviceWorker.ready
|
|
|
+ // .then((registration) => {
|
|
|
+ // registration.unregister();
|
|
|
+ // })
|
|
|
+ // .catch((error) => {
|
|
|
+ // console.error(error.message);
|
|
|
+ // });
|
|
|
+ // }
|
|
|
+ // }
|