fix(cache): add aggressive no-store middleware, CSP updates, and client-side service worker & cache purge

This commit is contained in:
2026-11-17 11:00:09 +05:30
parent 28dd3beb90
commit d49bd5c721
6 changed files with 95 additions and 5 deletions
+10 -5
View File
@@ -62,18 +62,23 @@ const nextConfig = {
key: 'Content-Security-Policy',
value: [
"default-src 'self'",
"script-src 'self' 'unsafe-inline' 'unsafe-eval' https://apis.google.com",
"style-src 'self' 'unsafe-inline' https://fonts.googleapis.com",
"font-src 'self' https://fonts.gstatic.com",
"script-src 'self' 'unsafe-inline' 'unsafe-eval' https://apis.google.com https://challenges.cloudflare.com",
"style-src 'self' 'unsafe-inline' https://fonts.googleapis.com https://fonts.cdnfonts.com",
"font-src 'self' https://fonts.gstatic.com https://fonts.cdnfonts.com data:",
"img-src 'self' data: blob: https:",
"connect-src 'self' https://*.firebaseapp.com https://*.googleapis.com https://identitytoolkit.googleapis.com https://securetoken.googleapis.com",
"frame-src 'self' https://accounts.google.com",
"connect-src 'self' https://*.firebaseapp.com https://*.googleapis.com https://identitytoolkit.googleapis.com https://securetoken.googleapis.com https://challenges.cloudflare.com",
"frame-src 'self' https://accounts.google.com https://challenges.cloudflare.com",
"object-src 'none'",
"base-uri 'self'",
"form-action 'self'",
...(isProd ? ["upgrade-insecure-requests"] : []),
].join('; '),
},
// Strict Cache-Control to prevent browsers & CDNs from serving stale HTML
{ key: 'Cache-Control', value: 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0, s-maxage=0' },
{ key: 'Pragma', value: 'no-cache' },
{ key: 'Expires', value: '0' },
{ key: 'Surrogate-Control', value: 'no-store' },
// Block clickjacking
{ key: 'X-Frame-Options', value: 'SAMEORIGIN' },
// Prevent MIME sniffing