Skip to content

fix: resolve SESSION_SECRET lazily to unblock production build#29

Merged
ralyodio merged 1 commit into
masterfrom
fix/build-session-secret-lazy
Jun 16, 2026
Merged

fix: resolve SESSION_SECRET lazily to unblock production build#29
ralyodio merged 1 commit into
masterfrom
fix/build-session-secret-lazy

Conversation

@ralyodio

Copy link
Copy Markdown
Contributor

Problem

Every Railway deploy since #20 (remove hardcoded session secret fallback) has failed to build. The last successful deploy was #24; #20 and everything after fails at:

Error: SESSION_SECRET environment variable is required
  at app/api/auth/me/route.js
Failed to collect page data for /api/auth/me

SESSION_SECRET is set on the Railway service, but #20 throws at module import time, and next build imports API route modules during "Collecting page data" — so the top-level throw aborts the build.

Fix

Move the check into a lazy getSessionSecret() invoked from hmac() at request time. This preserves #20's security intent (no insecure fallback; requests still fail if the secret is unset) while letting the build import route modules cleanly.

Verification

next build now succeeds locally with SESSION_SECRET unset (reproducing the build env). Previously this threw; now the full route manifest builds.

🤖 Generated with Claude Code

PR #20 removed the insecure SESSION_SECRET fallback by throwing at
module import when the env var is unset. But `next build` imports API
route modules during "Collecting page data", so the top-level throw
broke every deploy after #20 (build failed at /api/auth/me with
"SESSION_SECRET environment variable is required").

Move the check into a lazy getSessionSecret() called from hmac() at
request time. This preserves #20's security intent (no fallback,
requests fail if unset) while letting the build import route modules
cleanly. Verified: `next build` now succeeds with SESSION_SECRET unset.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

vu1nz Security Review

0 finding(s) in PR #?

No security issues found.

@ralyodio ralyodio merged commit 778da01 into master Jun 16, 2026
5 checks passed
@ralyodio ralyodio deleted the fix/build-session-secret-lazy branch June 16, 2026 12:22
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.

1 participant