Skip to content

Commit

Permalink
redirect handling
Browse files Browse the repository at this point in the history
  • Loading branch information
EduardZaydler committed Oct 16, 2024
1 parent def5e59 commit 059be5a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
13 changes: 7 additions & 6 deletions service-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ precacheAndRoute(self.__WB_MANIFEST);
// }

self.addEventListener("fetch", (event) => {
console.log("Fetch event triggered");

const fetchEvent = event;
const url = fetchEvent.request.url;
if (url.includes("oauth")) {
fetchEvent.respondWith(fetch(fetchEvent.request));
const { request } = event;
const url = new URL(request.url);
console.log(request.mode);
console.log("path includes redirect:", url.pathname.includes("redirect"));
if (url.pathname.includes("redirect") || request.mode === "navigate") {
console.log("Fetch event triggered for redirect navigation");
fetchEvent.respondWith(fetch(request));
}
});
8 changes: 4 additions & 4 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ module.exports = {
// that's why size is sincreased to 6mb

maximumFileSizeToCacheInBytes: 6291456,
// cleanupOutdatedCaches: true,
// clientsClaim: true,
// sourcemap: false,
// skipWaiting: true,
cleanupOutdatedCaches: true,
clientsClaim: true,
sourcemap: false,
skipWaiting: true,
swSrc: "/service-worker.js",
swDest: "service-worker.js",
}),
Expand Down

0 comments on commit 059be5a

Please sign in to comment.