fix: require AUTH_URL in production - #49
Merged
Merged
Conversation
Without AUTH_URL, the production server built the GitHub callback URL from its own bind address (http://0.0.0.0:3000), and forwarded host headers did not change it, so sign-in failed behind a proxy. AUTH_URL is now validated and required when NODE_ENV is production, and it is documented in .env.example and the deployment checklist. Signed-off-by: voidash <ashish.thapa477@gmail.com>
abhiyandhakal
approved these changes
Sep 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
The production server now requires
AUTH_URL, the public origin of the site. Without it, the GitHub OAuth callback URL was built from the container's bind address (http://0.0.0.0:3000/...), so sign-in failed behind any proxy. Forwarded host headers did not change that.apps/api/src/config.ts:AUTH_URLis validated, and required whenNODE_ENVisproduction. Validation moves into a pureparseEnv()so it can be tested;getEnv()still caches the result.apps/api/.env.example:AUTH_URL=http://localhost:3000, with a comment.docs/deployment.md: the OAuth step namesAUTH_URL, and there is a known-problems row for the callback mismatch.Closes #48
Contract impact
packages/api-contractChecks
bun run lintbun run typecheckbun run test(153 passed, including 3 new tests; the production test fails if the rule is removed)bun run buildChecked against a production container, reading the callback URL from
/api/auth/providers:AUTH_URL, anyHostheaderhttp://0.0.0.0:3000/api/auth/callback/githubAUTH_URL, withX-Forwarded-HostandX-Forwarded-Proto: httpshttps://0.0.0.0:3000/...(host still wrong)AUTH_URL=https://devnepal.gov.nphttps://devnepal.gov.np/api/auth/callback/githubX-Forwarded-HostAUTH_URLoriginNotes for reviewers
Any existing deployment must set
AUTH_URLbefore running this version: the app now refuses to start without it, instead of starting with broken sign-in.Foundation checklist
git commit -s)