1
0
forked from maik/IPFS-portal

fix: bw/stats 404, gateway links, history crash

- swr.ts: remove useBandwidth(), drop bw from useDashboard()
- events/route.ts: skip bandwidth SSE (Kubo 0.28.0 unsupported)
- usage/page.tsx: remove getBWStats call + bw references
- helpers.ts: gatewayLink -> ipfs.maos.dedyn.io (subdomain only)
- upload/page.tsx: fix local gatewayLink (subdomain only)
- storage.ts: update default gatewayUrl, add defensive getHistory()
This commit is contained in:
maikrolf
2026-07-05 17:03:18 +02:00
9 changed files with 35 additions and 20 deletions
+10 -3
View File
@@ -69,6 +69,11 @@ self.addEventListener('fetch', (event) => {
// Same-origin only
if (url.origin !== self.location.origin) return;
// Only cache GET/HEAD — POST/PUT/DELETE/OPTIONS can't use Cache API
if (request.method !== 'GET' && request.method !== 'HEAD') {
return; // pass through, no caching
}
// 1. Static assets → cache-first
if (isStaticAsset(url)) {
event.respondWith(cacheFirst(request, STATIC_CACHE));
@@ -98,7 +103,8 @@ async function cacheFirst(request, cacheName) {
if (cached) return cached;
try {
const response = await fetch(request);
if (response.ok) {
// Cache API supports GET/HEAD only
if (response.ok && request.method === 'GET') {
const cache = await caches.open(cacheName);
cache.put(request, response.clone());
}
@@ -111,7 +117,8 @@ async function cacheFirst(request, cacheName) {
async function networkFirst(request, cacheName) {
try {
const response = await fetch(request);
if (response.ok) {
// Cache API supports GET/HEAD only — POST/PUT/DELETE must be skipped
if (response.ok && request.method === 'GET') {
const cache = await caches.open(cacheName);
cache.put(request, response.clone());
}
@@ -129,7 +136,7 @@ async function staleWhileRevalidate(request, cacheName) {
const fetchPromise = fetch(request)
.then((response) => {
if (response.ok) cache.put(request, response.clone());
if (response.ok && request.method === 'GET') cache.put(request, response.clone());
return response;
})
.catch(() => cached);