mejorando configuracion de seguridad
This commit is contained in:
@@ -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]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user