🔧(service-worker) add conf file with dev urls
Add a conf files to the service worker to store the development urls. If someone wants to change the urls, they can do it in the conf file, it is more intuitive than changing the urls in the service worker file.
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
export const SW_DEV_URL = [
|
||||
'http://localhost:3000',
|
||||
'https://impress.127.0.0.1.nip.io',
|
||||
'https://impress-staging.beta.numerique.gouv.fr',
|
||||
];
|
||||
@@ -19,6 +19,7 @@ import {
|
||||
|
||||
// eslint-disable-next-line import/order
|
||||
import { ApiPlugin } from './ApiPlugin';
|
||||
import { SW_DEV_URL } from './conf';
|
||||
import { isApiUrl } from './service-worker-api';
|
||||
|
||||
// eslint-disable-next-line import/order
|
||||
@@ -50,13 +51,7 @@ const getCacheNameVersion = (cacheName: string) =>
|
||||
const getStrategy = (
|
||||
options?: NetworkFirstOptions | StrategyOptions,
|
||||
): NetworkFirst | CacheFirst => {
|
||||
const devDomains = [
|
||||
'http://localhost:3000',
|
||||
'https://impress.127.0.0.1.nip.io',
|
||||
'https://impress-staging.beta.numerique.gouv.fr',
|
||||
];
|
||||
|
||||
return devDomains.some((devDomain) =>
|
||||
return SW_DEV_URL.some((devDomain) =>
|
||||
self.location.origin.includes(devDomain),
|
||||
)
|
||||
? new NetworkFirst(options)
|
||||
|
||||
Reference in New Issue
Block a user