Skip to content

fix: disable secure cookie flag in local dev and harden JWT payload#308

Open
jakebromberg wants to merge 2 commits intomainfrom
bugfix/auth-local-dev
Open

fix: disable secure cookie flag in local dev and harden JWT payload#308
jakebromberg wants to merge 2 commits intomainfrom
bugfix/auth-local-dev

Conversation

@jakebromberg
Copy link
Copy Markdown
Member

Summary

  • Disable the Secure cookie flag in non-production environments so session cookies work over http://localhost
  • Add try-catch to the JWT definePayload member role query so DB failures degrade gracefully instead of 500ing
  • Switch member role query from raw sql template to type-safe eq()
  • Include request method and URL in error handler logs for easier debugging

Closes #307

Test plan

  • Log in at http://localhost:3000 with test credentials — session cookie should be set and redirect to dashboard should work
  • Verify the Secure flag is NOT present on the session cookie in local dev
  • Verify the Secure flag IS present when NODE_ENV=production
  • Stop the database and attempt login — should fail gracefully (no 500 from JWT generation)
  • Verify error handler logs include [METHOD /url] prefix

Jake Bromberg added 2 commits April 6, 2026 07:28
The session cookie's `secure` flag was hardcoded to `true`, which prevented browsers from storing cookies over plain `http://localhost`. This broke login redirect in local development because the sign-in API succeeded but the session was never established.

Also adds error handling to the JWT `definePayload` function so a database failure during member role lookup degrades gracefully instead of returning a 500, and switches from raw SQL template to `eq()` for type safety.

Improves the error handler to include request method and URL in log output for easier debugging.
Add method and url to mock request object and update the expected console.error call to include the request context prefix.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix secure cookie flag blocking local dev login

1 participant