seguimos
All checks were successful
build-and-deploy / build (push) Successful in 23s
build-and-deploy / deploy (push) Successful in 2s

This commit is contained in:
2025-10-11 18:43:53 -06:00
parent 811b525cfc
commit c56f06034e
2 changed files with 32 additions and 5 deletions

View File

@@ -96,6 +96,10 @@ export default defineNuxtConfig({
}
},
// API Music list: Network-First with offline fallback
// IMPORTANTE: Esta ruta REQUIERE autenticación via Authentik
// - Online + Autenticado: Fetches desde servidor (pasa por Authentik)
// - Online + NO autenticado: Authentik redirige a login (401/403)
// - Offline: Usa cache si existe
{
urlPattern: /\/api\/music$/,
handler: 'NetworkFirst',
@@ -107,11 +111,18 @@ export default defineNuxtConfig({
maxAgeSeconds: 60 * 5 // 5 minutes
},
cacheableResponse: {
// Solo cachea respuestas exitosas (200)
// NO cachea 401/403 (sin autenticación)
statuses: [0, 200]
}
}
},
// API Music files: Cache-First for downloaded tracks
// IMPORTANTE: Esta ruta REQUIERE autenticación via Authentik
// - Cache hit: Sirve desde cache (offline-ready, no requiere auth)
// - Cache miss + Online + Autenticado: Descarga y cachea
// - Cache miss + Online + NO autenticado: Falla con 401/403
// - Cache miss + Offline: Falla (app debe manejar el error)
{
urlPattern: /\/api\/music\/.+/,
handler: 'CacheFirst',
@@ -122,14 +133,17 @@ export default defineNuxtConfig({
maxAgeSeconds: 60 * 60 * 24 * 30 // 30 days
},
cacheableResponse: {
// Solo cachea respuestas exitosas
// NO cachea 401/403/404
statuses: [0, 200, 206] // Include partial content
},
plugins: [
{
// Handle authentication errors gracefully
handlerDidError: async ({ request }) => {
console.warn('[SW] Failed to fetch:', request.url)
// Return null to let the app handle the error
console.warn('[SW] Failed to fetch (posible error de auth o red):', request.url)
// Return null para que la app maneje el error
// La app puede mostrar mensaje de "requiere login" o "sin conexión"
return null
}
}