diff --git a/src/firebase/index.js b/src/firebase/index.js index df6a95a1..08f21834 100644 --- a/src/firebase/index.js +++ b/src/firebase/index.js @@ -32,7 +32,7 @@ const getConfig = () => { } if (import.meta.env.VITE_DB === 'prod') { // NOTE: Netlify secret - config = JSON.parse(process.env.REACT_APP_FIREBASE_CONFIG); + config = JSON.parse(import.meta.env.REACT_APP_FIREBASE_CONFIG); } return config; }; diff --git a/src/registerServiceWorker.js b/src/registerServiceWorker.js index c082515b..18bb8772 100644 --- a/src/registerServiceWorker.js +++ b/src/registerServiceWorker.js @@ -9,17 +9,17 @@ // This link also includes instructions on opting out of this behavior. const isLocalhost = Boolean( - window.location.hostname === 'localhost' + window.location.hostname === 'localhost' || // [::1] is the IPv6 localhost address. - || window.location.hostname === '[::1]' + window.location.hostname === '[::1]' || // 127.0.0.1/8 is considered localhost for IPv4. - || window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/), + window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/), ); export default function register() { - if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) { + if (import.meta.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); + const publicUrl = new URL(import.meta.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 @@ -28,7 +28,7 @@ export default function register() { } window.addEventListener('load', () => { - const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; + const swUrl = `${import.meta.env.PUBLIC_URL}/service-worker.js`; if (isLocalhost) { // This is running on localhost. Lets check if a service worker still exists or not. @@ -38,8 +38,8 @@ export default function register() { // 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://goo.gl/SC7cgQ', + 'This web app is being served cache-first by a service ' + + 'worker. To learn more, visit https://goo.gl/SC7cgQ', ); }); } else { @@ -85,8 +85,8 @@ function checkValidServiceWorker(swUrl) { .then((response) => { // Ensure service worker exists, and that we really are getting a JS file. if ( - response.status === 404 - || response.headers.get('content-type').indexOf('javascript') === -1 + response.status === 404 || + response.headers.get('content-type').indexOf('javascript') === -1 ) { // No service worker found. Probably a different app. Reload the page. navigator.serviceWorker.ready.then((registration) => {