From 3d6b8173b0534d182489e4f7a20b3569dca25e86 Mon Sep 17 00:00:00 2001 From: kagentz-bot Date: Wed, 24 Jun 2026 12:37:11 -0400 Subject: [PATCH] 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. --- nginx/nginx.conf | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/nginx/nginx.conf b/nginx/nginx.conf index 74eccd1..caa6fe2 100644 --- a/nginx/nginx.conf +++ b/nginx/nginx.conf @@ -140,6 +140,22 @@ http { 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 / { proxy_pass $litellm_backend_url/; proxy_http_version 1.1;