swagger-api / swagger-ui

Swagger UI is a collection of HTML, JavaScript, and CSS assets that dynamically generate beautiful documentation from a Swagger-compliant API.
https://swagger.io
Apache License 2.0
26.62k stars 8.96k forks source link

Accessing swagger ui endpoints behind a reverse proxy? #7957

Open mautini opened 2 years ago

mautini commented 2 years ago

Q&A (please complete the following information)

How can we help?

Let's assume I have a Flask app exposing an endpoint /login and I expose this app behind a reverse proxy (traefik) using the prefix my_app (the proxy has to strip the prefix, however when I use the "try it out" function in swagger ui, it send the request to /my_app/login and my app doesn't know this route).

With this configuration, I can't reach the Swagger UI: if I set url_prefix to my_app in Flask configuration, the documentation will be exposed on /my_app/apidocs but the proxy will strip the first part of the path. I can "cheat" by accessing /my_app/my_app/apidocs but the page doesn't load (css, js etc...) because it will call my_app/swagger-ui-bundle.js for example (and the my_app will be stripped by the proxy).

Is there any way to set the prefix only when accessing the ressources of the swagger ui?

To recap I would like to have the following endpoints exposed :

but when I'm loading the ui, I would like to perform requests to /my_app/* (similarly to the try it out functionality where I can use basePath

Thanks

kzlsahin commented 1 week ago

Isn't there any progress since 2022?