Menu

A readable cookie mirrors our httpOnly session, so a static page can offer My account
📰

A readable cookie mirrors our httpOnly session, so a static page can offer My account

DEV Community: nextjs·Daniel Pertu·2 days ago
#KrI8OjkA
#devtonextjs#devto#dev#cookie#session
Reading 0:00
15s threshold

Most of our traffic lands on a public page: a provider page, a test-format page, an employer guide. Those pages are statically rendered, and every one of them ends in a "Sign Up" button.

If you already have an account, that button is wrong. It is not broken, you end up in the right place eventually, but offering sign-up to someone who signed up last week is the kind of small wrongness that makes a product feel like it is not paying attention.

The obvious fix is not available. Supabase's session cookies are httpOnly , so the page's own JavaScript cannot see them, and that is the correct setting for a session cookie. The other obvious fix is to ask the server, and that puts an auth round trip behind a page view whose whole point is that it is cached HTML.

So the middleware mirrors one bit.

Presence, not identity

/** * Whether any of these cookies is a Supabase session cookie: * `sb-<project>-auth-token`, or one of its `.0`, `.1` chunks when the session * is too large for a single cookie.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.