Cookie Authentication (Frontend)
Use this skill when adding cookie-based authentication to a Furo/Nuxt app — holding the session, renewing the access token on a 401, guarding routes, signing out, or serving same-origin.
The app keeps a short-lived access token in a Nuxt useState store (never localStorage) and sends it as a header on every request; the refresh token is an HttpOnly cookie the browser sends on its own. When the access token expires the app renews it from the cookie and retries the request once; sign-out revokes the cookie server-side. Every decision lives in a plain, injectable class ([[hoc-jest]]-tested); the composable and middleware are thin Nuxt-context bridges. The refresh cookie is first-party only when the app is served same-origin with the API.
The pattern starts at password sign-in, where the app holds an access token. An OIDC or SSO sign-in reaches the same session: its callback returns the same access token and sets the same refresh cookie, and [[hof-oidc-sign-in]] covers the trip to the provider. A backend that keeps a session cookie and returns no token at all leaves the app nothing to hold, so this skill does not apply to it.
This is application code built on top of the boilerplate's generic BaseAppGraphql* classes ([[hof-graphql]]) — it is not in the boilerplate itself. The boilerplate's base payload also looks for a token in localStorage; this skill writes nothing there, so the token reaches each request only through the session store.
Depends on the backend cookie-authentication skill for the token schema, cookie context, and the
signIn/renewAccessToken/signOutresolvers. Binding the server to loopback is a separate server-hardening concern, not part of this skill.
Core
| Topic | Description | Reference |
|---|---|---|
| Session state | The useSessionStore Nuxt store and the SessionStoreClerk gate — the in-memory access token, with the store injected into plain classes | session-state |
| Renew | SessionRenewer — renew the access token from the cookie, deduplicating concurrent refreshes | renew |
| Request healing | SessionRequestRunner + SessionRequestAuthorizer + useAppGraphqlClient — attach the token, renew and retry on Unauthenticated, revoke on RefreshTokenReused | request-healing |
| Route gateway | SessionGatekeeper + the global gateway middleware — ensure a session on guarded navigation | gateway |
| Sign-out | SessionRevoker + the signOut client + the sign-out UI trigger — revoke server-side, then drop the token | sign-out |
| Auth GraphQL clients | The signIn / renewAccessToken / signOut Launcher/Payload/Capsule trios on the base classes | auth-clients |
| Error codes | app/constants-error.js plus the capsule isUnauthenticated() / isRefreshTokenReused() checks | error-codes |
| Same-origin | Relative .furo-env endpoints, the vite dev proxy, and the production reverse proxy (nginx sample) | same-origin |


