Skip to content

Failed load UI behind reverse proxy (Failed to load API definition) #736

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
krummerd opened this issue Jun 17, 2020 · 5 comments
Closed
Labels
bug Something isn't working

Comments

@krummerd
Copy link

There're two microservices: Api Gateway (http://localhost:8080/) & User (http://localhost:8082/).

If you make a first request to swagger for User through Api Gateway: http://localhost:8080/user/ the config will be generated, but when you try to get User config from direct request to http://localhost:8082/ we can see Fail.
And also it's doesn't work vice versa:
if your first is a direct request without Api Gateway: http://localhost:8082/ then User config will be generated, but when you try to get User config through Api Gateway(http://localhost:8080/user/).

I think this can be fixed, for example, for each request we can generate configs, without caching.
But springdoc.cache.disabled doesn't help.

image

@bnasslahsen
Copy link
Collaborator

There is no known issues on reverse project.

You can have a look at the necessary configuration if you are using a reverse proxy in this section:

And this is the link to a sample code using spring-cloud-gateway in microservices architecture:

@krummerd
Copy link
Author

I had written an example of the project with the failure.
And one more, we defined that problem shows when we work with Groups. Without groups works well.

https://github.com/krummerd/openapi-issue/tree/master/openapi-gateway

@bnasslahsen bnasslahsen reopened this Jun 19, 2020
@oursy
Copy link

oursy commented Jun 20, 2020

The current springdoc version is 1.41

I also encountered the same problem.
I investigated and found that the problem should be
File SwaggerUiConfigProperties: line 195 caused

Steps to reproduce:

If it is accessed through the gateway for the first time, the initial urls object is /user/ v3/api-docs/api

If you access it through user service at one time, the url is /v3/api-docs/api but when you first access through the gateway, the url of the SwaggerUrl object has already been assigned.
However, due to the if (StringUtils.isBlank(elt.url)) judgment, / v3/api-docs/api did not succeed.

Conversely, if you access user service for the first time, access via the gateway will also fail

During the investigation, it was found that the oauth2RedirectUrl attribute has a similar situation

@bnasslahsen
Copy link
Collaborator

bnasslahsen commented Jun 21, 2020

@krummerd,

Thanks to your sample code, the issue you are facing is now reproducible.

@krummerd, @oursy

A fix is now available on master, and you can already validate it with the latest snapshot.(1.4.2-SNAPSHOT)

@oursy
Copy link

oursy commented Jun 21, 2020

Upgrade to 1.4.2-SNAPSHOT problem solved

But there is another problem 1.4.1 version file SwaggerUiConfigProperties.addGroup method was deleted

After some searching, addGroup was moved to the SwaggerUiConfigParameters file. It works normally after replacing the original SwaggerUiConfigProperties file.

@bnasslahsen bnasslahsen added the bug Something isn't working label Jan 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants