Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
EduardZaydler committed Oct 15, 2024
1 parent 61915b3 commit a2dad0a
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions src/serviceWorkerRegistration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,23 @@ interface CustomFetchEvent extends Event {
request: Request;
respondWith(response: Promise<Response> | Response): void;
}
// excluding auth api calls from sw handling
self.addEventListener("fetch", (event: Event) => {
const fetchEvent = event as CustomFetchEvent;
const url = fetchEvent.request.url;
console.log(event);
if (url.includes("oauth") || url.includes("api")) {
fetchEvent.respondWith(fetch(fetchEvent.request));
}
});

export function register(onUpdate: () => void) {
// excluding auth api calls from sw handling
self.addEventListener("fetch", (event: Event) => {
console.log("Fetch event triggered"); // Добавьте это

const fetchEvent = event as CustomFetchEvent;
const url = fetchEvent.request.url;
if (url.includes("oauth") || url.includes("api")) {
fetchEvent.respondWith(
fetch(fetchEvent.request, {
mode: "cors",
})
);
}
});

if ("serviceWorker" in navigator) {
window.addEventListener("load", async () => {
try {
Expand Down

0 comments on commit a2dad0a

Please sign in to comment.