Skip to content

Commit

Permalink
no-cors
Browse files Browse the repository at this point in the history
  • Loading branch information
EduardZaydler committed Oct 16, 2024
1 parent cd818f8 commit c1c9bf4
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions service-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,23 @@ async function stashInCache(cacheName, request, response) {
const pagesCacheName = "pages-cache-v1";

self.addEventListener("fetch", (event) => {
const { request } = event;
const { request, response } = event;
const url = new URL(request.url);
console.log(request.url, request.mode, request.redirect);
if (request.mode === "navigate") {
console.log("skppied navigate");
return;
console.log(
request.url,
request.mode,
request.redirect,
response.status,
`includes oauth:${url.includes("oauth")}`
);
if (url.includes("oauth")) {
request = new Request(url, {
method: "GET",
headers: request.headers,
mode: "no-cors",
credentials: request.credentials,
redirect: request.redirect,
});
event.respondWith(fetch(request));
}
});

0 comments on commit c1c9bf4

Please sign in to comment.