diff options
author | Kristóf Marussy <kristof@marussy.com> | 2022-08-19 21:23:31 +0200 |
---|---|---|
committer | Kristóf Marussy <kristof@marussy.com> | 2022-08-20 21:41:50 +0200 |
commit | beda5138e018d9a853d57bd7274a35c21fa5c366 (patch) | |
tree | 3f6ff98c917db824a850c85eee7fbd76021adc27 /subprojects/frontend/src | |
parent | feat(frontend): add PWA manifest (diff) | |
download | refinery-beda5138e018d9a853d57bd7274a35c21fa5c366.tar.gz refinery-beda5138e018d9a853d57bd7274a35c21fa5c366.tar.zst refinery-beda5138e018d9a853d57bd7274a35c21fa5c366.zip |
fix(frontend): destroy service worker in dev mode
If the application is run in both production and development mode on the
same domain, make sure to clean up the production service worker.
Diffstat (limited to 'subprojects/frontend/src')
-rw-r--r-- | subprojects/frontend/src/RegisterServiceWorker.tsx | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/subprojects/frontend/src/RegisterServiceWorker.tsx b/subprojects/frontend/src/RegisterServiceWorker.tsx index c9b2e353..5f46bc3d 100644 --- a/subprojects/frontend/src/RegisterServiceWorker.tsx +++ b/subprojects/frontend/src/RegisterServiceWorker.tsx | |||
@@ -50,7 +50,8 @@ function UpdateSnackbarActions({ | |||
50 | export default function RegisterServiceWorker(): null { | 50 | export default function RegisterServiceWorker(): null { |
51 | const { enqueueSnackbar, closeSnackbar } = useSnackbar(); | 51 | const { enqueueSnackbar, closeSnackbar } = useSnackbar(); |
52 | useEffect(() => { | 52 | useEffect(() => { |
53 | if (import.meta.env.DEV) { | 53 | if (window.location.host === 'localhost') { |
54 | // Do not register service worker during local development. | ||
54 | return; | 55 | return; |
55 | } | 56 | } |
56 | if (!('serviceWorker' in navigator)) { | 57 | if (!('serviceWorker' in navigator)) { |