🔧(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:
Anthony LC
2024-06-26 16:51:04 +02:00
committed by Anthony LC
parent cfb979a411
commit 287a5b3bff
2 changed files with 7 additions and 7 deletions

View File

@@ -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',
];

View File

@@ -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)