fix(nginx): stop stripping the /api/ prefix on proxy_pass#30
Merged
Conversation
api mounts every route under /api/* internally (src/app.ts:
app.use('/api/auth', ...), app.use('/api/users', ...), etc. — confirmed
against the v0.7.0 tag currently pinned in docker-compose.yml). The
trailing slash on proxy_pass rewrites the location's matched prefix away
before forwarding, so nginx was sending e.g. /auth/login to the backend
instead of /api/auth/login — every API route would 404 behind this
config as currently pinned.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Up to standards ✅🟢 Issues
|
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
Both
proxy.nginx.confandproxy-tls.nginx.confproxy_pass to the api backend with a trailing slash on the URL (proxy_pass http://api:8080/;). In nginx, that rewrites away the matchedlocation /api/prefix before forwarding — so a request to/api/auth/loginreaches the backend as/auth/login.api mounts every route under
/api/*internally:So as currently pinned, every request through this proxy config would 404 against the real api routes — nginx needs to forward the full
/api/...path unchanged.Change
Drop the trailing slash on both
proxy_passdirectives so the full request URI is forwarded as-is.Test plan
v0.7.0tag viagit grep "app.use('/api"— all routers expect the/api/prefix🤖 Generated with Claude Code