Skip to content

chore: improve qol when missing a sessionCookeSecret#895

Merged
stevenle merged 4 commits intomainfrom
chore/session-secretr
Feb 2, 2026
Merged

chore: improve qol when missing a sessionCookeSecret#895
stevenle merged 4 commits intomainfrom
chore/session-secretr

Conversation

@jeremydw
Copy link
Member

This is a small PR that improves the QOL for local dev when no sessionCookieSecret is specified, and adds a clear log with a warning if the project is deployed to prod without a session cookie secret (to maintain backwards compatibility with the previous behavior.)

@jeremydw jeremydw requested a review from stevenle January 30, 2026 03:25
@stevenle
Copy link
Member

i'm a little worried about this change creating too much noise for people who don't use cookies. we need to provide a way to silence the error or be more deterministic about whether cookies are even used before issuing the warning.

it's currently provided in root by default because i couldn't figure out a better way to have root-cms inject it while making it available for use across other plugins.

@jeremydw
Copy link
Member Author

ah i didn't realize it wasn't part of root-cms - just root. i removed the warning. now the only change the PR is introducing is using a deterministic session cookie in dev mode only. thoughts?

* This ensures the same secret is generated for the same seed across dev server restarts,
* while still allowing different projects to have unique secrets.
*/
export function deterministicSessionSecret(seed: string): string {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove export here since this is an internal implementation function

* Priority order:
* 1. Explicit config value (rootConfig.server.sessionCookieSecret)
* 2. Development mode: deterministic secret based on rootDir (sessions persist across restarts)
* 3. Production mode: random secret with security warning
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update docstring

return rootConfig.server.sessionCookieSecret;
}

if (process.env.NODE_ENV === 'development') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: can you include a short jscomment explaining this line

@jeremydw
Copy link
Member Author

jeremydw commented Feb 2, 2026

updated all

@stevenle stevenle merged commit 00373a7 into main Feb 2, 2026
1 check passed
@stevenle stevenle deleted the chore/session-secretr branch February 2, 2026 21:10
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.

2 participants