fix(server): add trustProxy support for reverse proxy deployments#70
Merged
Conversation
When running behind a reverse proxy (e.g., nginx for SSL termination), Fastify needs trustProxy enabled to correctly handle X-Forwarded-* headers. Without this, secure cookie handling and response headers can break, causing 502 errors from the upstream proxy. Adds TRUST_PROXY env var (default: false) to Fastify constructor and AppConfig, with validation and logging. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
|
🎉 This PR is included in version 1.7.0-beta.12 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Contributor
|
🎉 This PR is included in version 1.7.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
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.
Summary
TRUST_PROXYenv var (defaultfalse) to enable Fastify'strustProxywhen running behind a reverse proxy (e.g., nginx for SSL termination)POST /api/auth/setupdue to premature upstream connection closure.env.exampledocumentation, and 5 new unit testsChanges
server/src/app.ts— passtrustProxyto Fastify constructor fromTRUST_PROXYenv varserver/src/plugins/config.ts— addtrustProxytoAppConfiginterface, parsing, validation, and log output.env.example— documentTRUST_PROXYoption under Server sectionserver/src/plugins/config.test.ts— addtrustProxy: falseto all default assertions + 5 new TRUST_PROXY testsTest plan
npm run lint— 0 errorsnpm run format:check— cleannpm run typecheck— all 3 workspaces cleannpm test— 613 tests pass (34 suites)npm run build— succeedsnpm audit— 0 vulnerabilitiesTRUST_PROXY=true, verifyPOST /api/auth/setupsucceeds🤖 Generated with Claude Code