Closed mgagliardo91 closed 2 years ago
What is I did this on the client?
customOptions.oauth2RedirectUrl = customOptions.oauth2RedirectUrl || window.location.href + 'oauth2-redirect.html'
Essentially setting the oauth2RedirectUrl property automatically to the window href if now defined.
Referring to https://github.com/swagger-api/swagger-ui/pull/7476 Swagger UI is updated, the default oauth2RedirectUrl will also include sub-pages. I see swagger-ui dependency is still 4.3.0, can this be updated? After that we can fall back to the default redirect-url to solve this issue.
Currently, SwaggerUI accepts an argument (which is passed via
swaggerOptions
) to setoauth2RedirectUrl
. If this value is not set, it will default to${window.location.protocol}//${window.location.host}/oauth2-redirect.html
.I would like to expose Swagger UI Express at the route
/api-docs
. Unfortunately this means, without setting theoauth2RedirectUrl
manually, that the redirect path will still be{host}:{port}/oauth2-redirect.html
and the swagger-ui-express middleware will not catch the redirect route (since it binds its routes to/api-docs
).One way around this is to explicitly set the
oauth2RedirectUrl
in theswaggerOptions
payload to{host}:{port}/api-docs/oauth2-redirect.html
; however, this requires the express server to know its hostname ahead of time where as I would prefer to keep it ignorant to its hostname and keep everything relative.I am proposing having swagger-ui-express override the
oauth2RedirectUrl
to the route its running behind (i.e./api-docs
). You can take this a step further and make it configurable, but just having it on a non-root route without having to explicitly call out the hostname would be ideal.An alternative would be to allow passing a relative path for
oauth2RedirectUrl
and formatting it with thewindow.location
as swagger-ui does before its passed to the swagger ui bundle.Thanks!