Skip to content

Generated Server URL gets cached #283

Closed
@atetzner

Description

@atetzner

My application is reachable from two different URLs - an intranet and an internet URL. The first time the SwaggerUI is called, the server URL for the SwaggerUI is calculated and after that it is used from a cache (?) for all other calls to the SwaggerUI. For me this means, that e.g. a user from the internet will have the intranet URL in the "Server" dropdown, just because the first call to the SwaggerUI has been performed from the intranet. In this case, the user is unable to use the SwaggerUI, as calls go to the intranet URL, which is not reachable from internet.

Steps to reproduce

  • On your local machine, create an alias in /etc/hosts:
    127.0.0.1       springdoc
    
  • Start the application
  • Open up http://localhost:8080/swagger-ui.html: The "Servers" dropdown contains http://localhost:8080
  • Open up http://springdoc:8080/swagger-ui.html:
    • Expected: The "Servers" dropdown contains http://springdoc:8080
    • Actual: The "Servers" dropdown contains http://localhost:8080

Workaround

I know that it is possible to define the server URLs manually using the OpenAPI() object or annotations. Unfortunately this is no real solution for me for two reasons: First I don't want to expose the intranet URL to internet users for security reasons. Additionally the URLs for my DEV, INT and PROD environment are different and as the calculation of the server URL at runtime is possible, I don't want to have it hardcoded somewhere.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions