-
-
Notifications
You must be signed in to change notification settings - Fork 534
Description
This ticket could be closed, but I think it would be good to link this information to #2068 and #2058
I had another look at #2058
The suggested fix, to add
proxy_set_header X-Forwarded-Prefix $http_x_forwarded_prefix;
results in, on accessing http://localhost:8080/api/petstore/v3/api-docs/swagger-config
{"configUrl":"/petstore/v3/api-docs/swagger-config","oauth2RedirectUrl":"http://localhost:8080/petstore/swagger-ui/oauth2-redirect.html","url":"/petstore/v3/api-docs","validatorUrl":""}
which omits the /api
prefix (the $http_x_forwarded_prefix
nginx variable being probably set upstream connections to nginx, of which there are not any, so it defaults to "").
However the issue appears to be Spring-related, rather than related to springdoc-openapi. If an X-Forwarded-Prefix
is present, then Spring will use this to replace the context-path; not append it to the context-path.
There was a discussion on whether it should replace or prepend here: spring-projects/spring-framework#18949
I think the desired behaviour can be achieved by the following:
proxy_set_header X-Forwarded-Prefix /api/petstore;
which results in the correct response, on accessing http://localhost:8080/api/petstore/v3/api-docs/swagger-config
{"configUrl":"/api/petstore/v3/api-docs/swagger-config","oauth2RedirectUrl":"http://localhost:8080/api/petstore/swagger-ui/oauth2-redirect.html","url":"/api/petstore/v3/api-docs","validatorUrl":""}
Thank you for looking at the original issue.