Skip to content

Commit

Permalink
Merge pull request #190 from juliandescottes/fix-sw-example
Browse files Browse the repository at this point in the history
Do not try to install the service worker at the root
  • Loading branch information
teoli2003 authored Jan 23, 2023
2 parents 082b14a + 300f7f4 commit bdf9917
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion service-worker/simple-service-worker/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const registerServiceWorker = async () => {
const registration = await navigator.serviceWorker.register(
'sw.js',
{
scope: '/',
scope: './',
}
);
if (registration.installing) {
Expand Down
20 changes: 10 additions & 10 deletions service-worker/simple-service-worker/sw.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ self.addEventListener('activate', (event) => {
self.addEventListener('install', (event) => {
event.waitUntil(
addResourcesToCache([
'/',
'/index.html',
'/style.css',
'/app.js',
'/image-list.js',
'/star-wars-logo.jpg',
'/gallery/bountyHunters.jpg',
'/gallery/myLittleVader.jpg',
'/gallery/snowTroopers.jpg',
'./',
'./index.html',
'./style.css',
'./app.js',
'./image-list.js',
'./star-wars-logo.jpg',
'./gallery/bountyHunters.jpg',
'./gallery/myLittleVader.jpg',
'./gallery/snowTroopers.jpg',
])
);
});
Expand All @@ -78,7 +78,7 @@ self.addEventListener('fetch', (event) => {
cacheFirst({
request: event.request,
preloadResponsePromise: event.preloadResponse,
fallbackUrl: '/gallery/myLittleVader.jpg',
fallbackUrl: './gallery/myLittleVader.jpg',
})
);
});

0 comments on commit bdf9917

Please sign in to comment.