* don't mess with immutable request headers

* don't mess with requests outside the app (analytics, error tracking)
This commit is contained in:
m5r 2022-06-27 13:49:56 +02:00
parent cdd22bed76
commit eaf5d897ae
2 changed files with 5 additions and 2 deletions

View File

@ -30,7 +30,11 @@ self.addEventListener("message", (event) => {
}); });
self.addEventListener("fetch", (event) => { self.addEventListener("fetch", (event) => {
if (event.request.headers.get("Accept") === "text/event-stream") { const isSSERequest = event.request.headers.get("Accept") === "text/event-stream";
const isOutsideRequest = !["localhost", "dev.shellphone.app", "www.shellphone.app"].includes(
new URL(event.request.url).hostname,
);
if (isSSERequest || isOutsideRequest) {
return; return;
} }

View File

@ -68,7 +68,6 @@ export function fetchLoaderData(event: FetchEvent): Promise<Response> {
return caches.match(event.request, { cacheName: DATA_CACHE }).then((cachedResponse) => { return caches.match(event.request, { cacheName: DATA_CACHE }).then((cachedResponse) => {
console.debug(`Serving data from ${cachedResponse ? "cache" : "network"}`, path); console.debug(`Serving data from ${cachedResponse ? "cache" : "network"}`, path);
cachedResponse?.headers.set("X-Remix-Worker", "yes");
const timestamp = lastTimeRevalidated[path] ?? 0; const timestamp = lastTimeRevalidated[path] ?? 0;
const diff = Date.now() - timestamp; const diff = Date.now() - timestamp;