Skip to content

Commit

Permalink
fix(page): use qualified url for service worker
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-heimbuch committed Jul 15, 2024
1 parent 3803877 commit c355df3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 41 deletions.
37 changes: 0 additions & 37 deletions apps/page/src/features/LoadingOverlay.vue

This file was deleted.

2 changes: 0 additions & 2 deletions apps/page/src/layouts/Layout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import PageFooter from '../features/PageFooter.vue';
import LoadingBar from '../features/LoadingBar.vue';
import Subscribe from '../features/subscribe/Subscribe.vue';
import Colors from '../features/Colors.vue';
import LoadingOverlay from '../features/LoadingOverlay.vue';
import { store } from '../logic';
import { getLanguage } from '../i18n';
Expand All @@ -32,7 +31,6 @@ const lang = getLanguage();
</head>
<body>
<Colors client:only="vue" />
<LoadingOverlay client:load />
<LoadingBar client:only="vue" />
<PageHeader client:idle transition:persist="header" />
<main transition:animate="fade">
Expand Down
7 changes: 5 additions & 2 deletions apps/page/src/logic/sagas/serviceworker.sagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@ export default ({

const feed: string = yield select(selectFeed);
const cacheKey: string = yield select(selectCacheKey);
const baseUrl = new URL(document.location.href);

const serviceWorkerUrl = `${baseUrl.origin}${serviceWorker}?feed=${feed}&cacheKey=${cacheKey}`;

try {
const registration: ServiceWorkerRegistration = yield navigator.serviceWorker.register(
`${serviceWorker}?feed=${feed}&cacheKey=${cacheKey}`,
serviceWorkerUrl,
{
scope: '/'
}
Expand All @@ -35,7 +38,7 @@ export default ({

return function* () {
if(import.meta.env.MODE === 'production') {
yield registerServiceWorker();
yield registerServiceWorker();
}
};
};

0 comments on commit c355df3

Please sign in to comment.