admin/lib/expireRefreshSession.ts
alisaza e1eaf5eff5 feat: initial ghabilee-admin backoffice app
Extract admin dashboard from ghabilee-frontend2 into a dedicated Next.js
app for backoffice.ghabilee.ir (no SEO indexing / Clarity).
2026-09-05 13:12:59 +03:30

19 lines
649 B
TypeScript

import { CLEAR_REFRESH_SESSION_HEADER, CLEAR_REFRESH_SESSION_PATH } from '@/lib/refreshSessionCookie'
const CLEAR_SESSION_TIMEOUT_MS = 2500
/** Same-origin cookie expiry. Must run even when Nest logout failed. */
export const expireRefreshSessionOnThisOrigin = async (): Promise<void> => {
try {
await fetch(CLEAR_REFRESH_SESSION_PATH, {
method: 'POST',
credentials: 'same-origin',
headers: { [CLEAR_REFRESH_SESSION_HEADER]: '1' },
cache: 'no-store',
signal: AbortSignal.timeout(CLEAR_SESSION_TIMEOUT_MS),
})
} catch {
// Local storage is still wiped by AuthContext; this is cookie best-effort.
}
}