fix: add Cache-Control no-cache for HTML pages to prevent stale CDN content #41

Merged
uz1mani merged 5 commits from staging into main 2026-03-07 21:04:22 +00:00
8 changed files with 136 additions and 63 deletions
Showing only changes of commit 6338d1dfe7 - Show all commits

View File

@@ -26,10 +26,17 @@ function AuthCallbackContent() {
try {
result = await exchangeAuthCode(code, codeVerifier, redirectUri)
} catch {
// * Stale build — cached JS has old Server Action hashes. Hard reload to fix.
// * Stale build — cached JS has old Server Action hashes. Hard reload once to fix.
const key = 'pulse_reload_for_stale_build'
if (!sessionStorage.getItem(key)) {
sessionStorage.setItem(key, '1')
window.location.reload()
return
}
sessionStorage.removeItem(key)
setError('Something went wrong. Please try logging in again.')
return
}
if (result.success && result.user) {
// * Fetch full profile (including display_name) before navigating so header shows correct name on first paint
try {

View File

@@ -135,12 +135,21 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
let session: Awaited<ReturnType<typeof getSessionAction>> = null
try {
session = await getSessionAction()
sessionStorage.removeItem('pulse_reload_for_stale_build')
} catch {
// * Stale build — browser has cached JS with old Server Action hashes.
// * Force a hard reload to fetch fresh bundles from the server.
// * Force a hard reload once to fetch fresh bundles. Guard prevents infinite loop.
const key = 'pulse_reload_for_stale_build'
if (!sessionStorage.getItem(key)) {
sessionStorage.setItem(key, '1')
window.location.reload()
return
}
sessionStorage.removeItem(key)
// * Reload didn't fix it — treat as no session
setLoading(false)
return
}
// * 2. If no access_token but refresh_token may exist, try refresh (fixes 15-min inactivity logout)
if (!session && typeof window !== 'undefined') {
@@ -153,9 +162,16 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
try {
session = await getSessionAction()
} catch {
const key = 'pulse_reload_for_stale_build'
if (!sessionStorage.getItem(key)) {
sessionStorage.setItem(key, '1')
window.location.reload()
return
}
sessionStorage.removeItem(key)
setLoading(false)
return
}
}
}