mejorando configuracion de seguridad
All checks were successful
build-and-deploy / build (push) Successful in 26s
build-and-deploy / deploy (push) Successful in 3s

This commit is contained in:
2025-10-11 18:06:11 -06:00
parent 100ba45f57
commit d966fab4ca
3 changed files with 167 additions and 21 deletions

View File

@@ -39,27 +39,97 @@ export default defineNuxtConfig({
modules: [
'@vueuse/nuxt',
'@pinia/nuxt',
'@pinia/nuxt',
['@vite-pwa/nuxt', {
registerType: 'autoUpdate',
includeAssets: ['favicon.ico', 'logo.png', 'logo-192.png', 'logo-512.png', 'logo-maskable-512.png', 'icon.svg'],
workbox: process.env.NODE_ENV === 'production' ? {
navigateFallback: '/',
navigateFallbackDenylist: [
// Never cache authentication redirects
/^\/outpost\.goauthentik\.io/,
/^\/akprox/,
],
cleanupOutdatedCaches: true,
globPatterns: [
'**/*.{js,css,html,ico,png,svg}',
'_nuxt/**/*.{js,css}',
'assets/**/*.{png,jpg,jpeg,svg,gif,webp}'
],
// Exclude authentication and sensitive paths from precaching
globIgnores: [
'**/_payload.json',
'_nuxt/builds/**/*.json',
],
runtimeCaching: [
// Static images: Cache-First (offline-ready)
{
urlPattern: /\.(png|jpg|jpeg|svg|gif|webp)$/,
urlPattern: /\.(png|jpg|jpeg|svg|gif|webp|ico)$/,
handler: 'CacheFirst',
options: {
cacheName: 'images-cache',
expiration: {
maxEntries: 50,
maxAgeSeconds: 60 * 60 * 24 * 7 // 7 days
},
cacheableResponse: {
statuses: [0, 200]
}
}
},
// API Music list: Network-First with offline fallback
{
urlPattern: /\/api\/music$/,
handler: 'NetworkFirst',
options: {
cacheName: 'api-music-list',
networkTimeoutSeconds: 10,
expiration: {
maxEntries: 5,
maxAgeSeconds: 60 * 5 // 5 minutes
},
cacheableResponse: {
statuses: [0, 200]
}
}
},
// API Music files: Cache-First for downloaded tracks
{
urlPattern: /\/api\/music\/.+/,
handler: 'CacheFirst',
options: {
cacheName: 'music-files-cache',
expiration: {
maxEntries: 100,
maxAgeSeconds: 60 * 60 * 24 * 30 // 30 days
},
cacheableResponse: {
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
return null
}
}
]
}
},
// Nuxt build assets: Cache-First (immutable)
{
urlPattern: /\/_nuxt\/.+\.(js|css)$/,
handler: 'CacheFirst',
options: {
cacheName: 'nuxt-assets',
expiration: {
maxEntries: 100,
maxAgeSeconds: 60 * 60 * 24 * 365 // 1 year for hashed assets
},
cacheableResponse: {
statuses: [0, 200]
}
}
}