kopia lustrzana https://github.com/elk-zone/elk
fix(pwa): configure sw and web manifest cache control headers (#1724)
rodzic
c2ffdcf78b
commit
b9c2bc5c70
|
@ -79,6 +79,7 @@ export default defineNuxtModule<VitePWANuxtOptions>({
|
|||
if (entry) {
|
||||
res.statusCode = 200
|
||||
res.setHeader('Content-Type', 'application/manifest+json')
|
||||
res.setHeader('Cache-Control', 'public, max-age=0, must-revalidate')
|
||||
res.write(JSON.stringify(entry), 'utf-8')
|
||||
res.end()
|
||||
}
|
||||
|
@ -135,15 +136,22 @@ export default defineNuxtModule<VitePWANuxtOptions>({
|
|||
else {
|
||||
nuxt.hook('nitro:config', async (nitroConfig) => {
|
||||
nitroConfig.routeRules = nitroConfig.routeRules || {}
|
||||
nitroConfig.routeRules!['/sw.js'] = {
|
||||
headers: {
|
||||
'Cache-Control': 'public, max-age=0, must-revalidate',
|
||||
},
|
||||
}
|
||||
for (const locale of pwaLocales) {
|
||||
nitroConfig.routeRules![`/manifest-${locale.code}.webmanifest`] = {
|
||||
headers: {
|
||||
'Content-Type': 'application/manifest+json',
|
||||
'Cache-Control': 'public, max-age=0, must-revalidate',
|
||||
},
|
||||
}
|
||||
nitroConfig.routeRules![`/manifest-${locale.code}-dark.webmanifest`] = {
|
||||
headers: {
|
||||
'Content-Type': 'application/manifest+json',
|
||||
'Cache-Control': 'public, max-age=0, must-revalidate',
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
@ -122,6 +122,7 @@ export default defineNuxtConfig({
|
|||
'/manifest.webmanifest': {
|
||||
headers: {
|
||||
'Content-Type': 'application/manifest+json',
|
||||
'Cache-Control': 'public, max-age=0, must-revalidate',
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
Ładowanie…
Reference in New Issue