45ed282eed
ci / typecheck (map[dir:apps/booking name:booking]) (push) Successful in 20s
ci / typecheck (map[dir:apps/operator name:operator]) (push) Successful in 22s
ci / typecheck (map[dir:apps/portal name:portal]) (push) Successful in 21s
ci / typecheck (map[dir:apps/website name:website]) (push) Successful in 22s
ci / typecheck (map[dir:services/platform-api name:platform-api]) (push) Successful in 21s
ci / test (push) Successful in 31s
ci / build (map[dir:apps/booking name:booking]) (push) Successful in 9s
ci / build (map[dir:apps/operator name:operator]) (push) Successful in 30s
ci / build (map[dir:services/platform-api name:platform-api]) (push) Successful in 5s
ci / build (map[dir:apps/portal name:portal]) (push) Successful in 38s
ci / deploy (push) Successful in 42s
nuxt-oidc-auth registers its own 'oidc' storage mount at build, so
storage.mount('oidc', …) at runtime threw 'already mounted at oidc:' and
crash-looped the new pods. Unmount the memory mount first.
31 lines
1.2 KiB
TypeScript
31 lines
1.2 KiB
TypeScript
// Mount the nuxt-oidc-auth session store on Redis when configured.
|
|
//
|
|
// The module persists sessions via useStorage('oidc'); the default mount is
|
|
// per-pod memory, which 401s every request that lands on a replica that
|
|
// didn't mint the session AND drops all sessions on each deploy. Mounting at
|
|
// runtime (instead of nitro.storage in nuxt.config) keeps the Redis URL out
|
|
// of the build — same reason the OIDC provider config is env-driven.
|
|
//
|
|
// SESSION_REDIS_URL is set in production (fleet/apps/portal.yaml, value in
|
|
// portal-secrets). Unset in dev → in-memory mount stays, no Redis needed.
|
|
import redisDriver from 'unstorage/drivers/redis'
|
|
|
|
export default defineNitroPlugin(async () => {
|
|
const url = process.env.SESSION_REDIS_URL
|
|
if (!url) return
|
|
const storage = useStorage()
|
|
// The module ships its own build-time 'oidc' mount (memory driver) — it
|
|
// must be unmounted first or mount() throws 'already mounted at oidc:'.
|
|
await storage.unmount('oidc')
|
|
storage.mount(
|
|
'oidc',
|
|
redisDriver({
|
|
url,
|
|
base: 'oidc:portal',
|
|
// Safety net against orphaned sessions accumulating forever; well above
|
|
// any real session lifetime.
|
|
ttl: 60 * 60 * 24 * 14,
|
|
}),
|
|
)
|
|
})
|