fix: add dedicated location /openapi.json block to return spec JSON instead of SPA HTML
The nginx catch-all location / used proxy_pass $litellm_backend_url/ which stripped the URI path, causing /openapi.json to return the Swagger UI HTML page instead of the actual OpenAPI spec JSON. This broke the Swagger UI rendering with "Unable to render this definition" error. Fix: Add a dedicated location /openapi.json block before the catch-all / that preserves the full path, so LiteLLM returns its valid openapi: 3.1.0 spec JSON at the public endpoint.
This commit is contained in:
@@ -140,6 +140,22 @@ http {
|
|||||||
proxy_set_header Host $host;
|
proxy_set_header Host $host;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Dedicated /openapi.json block — must come before catch-all /
|
||||||
|
# LiteLLM serves valid openapi: 3.1.0 JSON at this path internally,
|
||||||
|
# but the catch-all location / strips the URI path. This block
|
||||||
|
# preserves the full path so the spec JSON is returned instead of
|
||||||
|
# the Swagger UI SPA HTML.
|
||||||
|
location /openapi.json {
|
||||||
|
proxy_pass $litellm_backend_url/openapi.json;
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header Authorization $http_authorization;
|
||||||
|
proxy_connect_timeout 10s;
|
||||||
|
proxy_read_timeout 600s;
|
||||||
|
proxy_buffering off;
|
||||||
|
}
|
||||||
|
|
||||||
location / {
|
location / {
|
||||||
proxy_pass $litellm_backend_url/;
|
proxy_pass $litellm_backend_url/;
|
||||||
proxy_http_version 1.1;
|
proxy_http_version 1.1;
|
||||||
|
|||||||
Reference in New Issue
Block a user