-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Auth/Sessions: Unable to set cookie in development #140
Comments
Thanks @dthyresson! I'm not sure why we haven't run into this for our own local development, but needing to not have I'll make a PR with both changes (no Secure in dev + flexibility to define cookie for store) |
Thanks! I forgot to note that I use Safari and perhaps they have more restrictive rules? Though I believe I tried Chrome as well. |
@dthyresson done! Will release shortly. We'll still need to document this, but for now here's an example of how to define how to create cookies: const sessions = defineDurableSession({
// ...
cookieName: "user_session",
createCookie: ({ name, sessionId, maxAge }) => `${name}=${sessionId}; Path=/; HttpOnly; Secure; SameSite=Lax; Max-Age=${maxAge ?? (7 * 24 * 60 * 60)}`
}); |
Released in 0.0.7! |
I followed the sessions starter and was able to setup sessions, the store and DO bingings.
I could tell in my local wrangler that the DO were being saved/stored on login.
However, the request didn't have the cookie set so I was never properly logged in when in development.
After some digging, I found that if I patched
createSessionCookie
so the cookie was not Secure (ie, needed https), then cookies were properly set, loaded from the request and auth behaved as expected.Perhaps something like this could work or maybe better yet some way of defining cookie props in
setupSessionStore(env)
?The text was updated successfully, but these errors were encountered: