Skip to content

Proxy Routing Cache Problem When Using Swagger-UI #1419

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
seymabatige opened this issue Jan 3, 2022 · 10 comments
Closed

Proxy Routing Cache Problem When Using Swagger-UI #1419

seymabatige opened this issue Jan 3, 2022 · 10 comments
Labels
invalid This doesn't seem right

Comments

@seymabatige
Copy link

Hi,

I've been migrating one of my applications from springfox to springdoc and I've run into the very same problem as in #331

I start both my application and the proxy. When I go to swagger ui directly from my application and then through the proxy, it seems to cache the config url and in one of two ways I get :
Failed to load remote configuration error. swagger-config gets 404 due to incorrectly created config url. (When I go through the application endpoint, it adds the forwarded prefix,
or when I go through the proxy, it lacks the forwarded prefix)

I added "server.forward-headers-strategy:framework" to my application yml file and in my swagger config class I added the following bean :

@Bean
fun forwardedHeaderFilter(): ForwardedHeaderFilter? {
    return ForwardedHeaderFilter()
}

I also disabled springdoc cache as suggested in issue 331. However, it didn't work and when I debug it seems to be caching the config url although springdoc cache is disabled.
My springdoc-openapi version is 1.6.3 and spring-boot version is 2.6.2

Thanks for your help

@bnasslahsen
Copy link
Collaborator

@seymabatige,

There are no known proxy issues. Note that demos are served behind proxies...

  • Why are you mentioning configURL which is not present by default in v1.6.3 (are you adding your own configUrl ...) ?

Your description is unclear. Try describing your steps to reproduce one by one. (Use GITHUB formatting).

  • Make sure you provide a Minimal, Reproducible Example - with HelloController that reproduces the problem
  • Share your poxy configuration.

@bnasslahsen
Copy link
Collaborator

@seymabatige,

This ticket will be closed and can be reopened if any relevant information is provided.

@bnasslahsen bnasslahsen added the invalid This doesn't seem right label Jan 9, 2022
@abenjell
Copy link

abenjell commented Jun 16, 2022

Hello @bnasslahsen ,
I reproduce the same described issue:
When I access to the swagger ui the first time behind the proxy it works fine:
URL with proxy : http://localhost/api/v0/myservice/swagger-ui/index.html
but when i access to the swagger with direct access ( url: http://localhost:8080/api/v0/swagger-ui/index.html) it doesn't work because it use the old config URL = "http://localhost:8080/api/v0/myservice/v3/api-docs/swagger-config".

The problem is that configUrl is not built each time even if the cache is disabled.
used versions
springdoc-openapi-ui : 1.6.9
spring-boot:2.6.6
Please find HelloController with nginxConfig

Thank you in advance for your help

@abenjell
Copy link

Hello @seymabatige,
Did you resolve the problem?
Thanks

@seymabatige
Copy link
Author

hi @abenjell actually I couldn't resolve the problem. Since I always access the endpoint through proxy, it does not create a problem in the actual environment.

@abenjell
Copy link

Ok thank you for your feedback @seymabatige

@antechrestos
Copy link

@seymabatige did you find a solution?
I observe the same behaviour with the same approach...

@bnasslahsen any news on the subject?

@antechrestos
Copy link

Apparently the issue also impacts automatically generated server url

@abenjell
Copy link

Hello,
for information i create new issue here:
#1712

@antechrestos
Copy link

I put a hack for this problem in #1712

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

4 participants