Serve Swagger spec per request so it works behind a proxy prefix.

The baked-in host and basePath pointed "Try it out" at the app's own listen
address, so requests from the browser never reached the server. doc.json is
now built from the incoming request, using X-Forwarded-Prefix to restore the
path prefix nginx strips before proxying.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-08 11:42:49 +05:00
parent ba53b5b5c2
commit 18012fcec0
2 changed files with 54 additions and 1 deletions

View File

@@ -68,6 +68,9 @@ server {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# The prefix is stripped above, so tell the app what it was: Swagger
# needs it to build URLs the browser can actually reach.
proxy_set_header X-Forwarded-Prefix /online-backend;
}
location = /favicon.ico { access_log off; log_not_found off; }