feat: expose optional API docs through frontend ingress (#416)

This commit is contained in:
Daniel Volz
2026-03-11 10:03:34 +01:00
committed by GitHub
parent 75196e5fa8
commit dd8ddb64e6
3 changed files with 50 additions and 4 deletions
+43
View File
@@ -23,6 +23,49 @@ server {
# Allow larger file uploads (for medication images and data import/export)
client_max_body_size 50M;
# -------------------------------------------------------------------------
# Swagger/OpenAPI docs (optional)
# When backend docs are enabled, expose them through the frontend ingress so
# no separate backend port is required for /docs access.
#
# Important: do not inherit the app-shell CSP here. Swagger UI ships its own
# CSP headers from Fastify and would otherwise be blocked by the stricter
# frontend policy.
# -------------------------------------------------------------------------
location = /docs {
resolver 127.0.0.11 valid=10s ipv6=off;
set $backend_upstream ${BACKEND_URL};
proxy_pass http://$backend_upstream;
proxy_set_header Host $host;
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;
proxy_pass_header Set-Cookie;
proxy_cookie_path / /;
# Defining a location-level header prevents inheritance of the stricter
# frontend app-shell headers while leaving backend Swagger headers intact.
add_header X-Docs-Proxy "1" always;
}
location ^~ /docs/ {
resolver 127.0.0.11 valid=10s ipv6=off;
set $backend_upstream ${BACKEND_URL};
proxy_pass http://$backend_upstream;
proxy_set_header Host $host;
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;
proxy_pass_header Set-Cookie;
proxy_cookie_path / /;
# Defining a location-level header prevents inheritance of the stricter
# frontend app-shell headers while leaving backend Swagger headers intact.
add_header X-Docs-Proxy "1" always;
}
location / {
try_files $uri /index.html;
}