fix: fall back on proxy error responses
This commit is contained in:
parent
e663f887cc
commit
d99ae4c25c
|
|
@ -123,6 +123,7 @@ self.addEventListener("fetch", (event) => {
|
||||||
if (event.request.mode === "navigate") {
|
if (event.request.mode === "navigate") {
|
||||||
event.respondWith(
|
event.respondWith(
|
||||||
fetch(event.request).then((response) => {
|
fetch(event.request).then((response) => {
|
||||||
|
if (!response.ok) throw new Error("navigation unavailable");
|
||||||
const copy = response.clone();
|
const copy = response.clone();
|
||||||
void caches.open(CACHE_NAME).then((cache) => cache.put("/", copy));
|
void caches.open(CACHE_NAME).then((cache) => cache.put("/", copy));
|
||||||
return response;
|
return response;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue