Skip to content

Commit

Permalink
event.respondwith
Browse files Browse the repository at this point in the history
  • Loading branch information
EduardZaydler committed Oct 10, 2024
1 parent 4a58dd5 commit 95c23cd
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/serviceWorkerRegistration.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
interface CustomFetchEvent extends Event {
request: Request;
respondWith(response: Promise<Response> | Response): void;
}

export function register(onUpdate: () => void) {
Expand All @@ -9,8 +10,8 @@ export function register(onUpdate: () => void) {
const fetchEvent = event as CustomFetchEvent;
if (fetchEvent.request && fetchEvent.request.url) {
const url = fetchEvent.request.url;
if (url.includes("/oauth2") || url.includes("/auth")) {
fetchEvent.stopImmediatePropagation();
if (url.includes("/oauth2") || url.includes("/api")) {
fetchEvent.respondWith(fetch(fetchEvent.request));
}
}
});
Expand Down

0 comments on commit 95c23cd

Please sign in to comment.