Skip to content

Swagger UI webflux webjars location with application context #2599

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
stuartkemp-e opened this issue May 23, 2024 · 1 comment
Closed

Swagger UI webflux webjars location with application context #2599

stuartkemp-e opened this issue May 23, 2024 · 1 comment
Labels
invalid This doesn't seem right

Comments

@stuartkemp-e
Copy link

Describe the bug

I have a webflux project which has a context-path set within spring config, and an additional context set externally (dev, staging, prod). The path I access swagger ui on locally is http://localhost:9990/my-app/swagger-ui/index.html. When I deploy to my server the path will be https://mydomain/dev/my-app/swagger-ui/index.html.

Swagger UI on my server fails to load because webjars are trying to be loaded from https://mydomain/my-app/webjars/swagger-ui/, which does not have the external context set (i.e. /dev).

I am aware of the springdoc.webjars.prefix option. If I set this to /dev/webjars, the path for the webjars becomes https://mydomain/my-app/dev/webjars/swagger-ui/, which is not correct in my case.

I have similar MVC applications. For these applications I can use configuration options to solve the problem (which manifests for swagger-config rather than webjars) like this:

springdoc:
  swagger-ui:
    config-url: /dev/my-app/swagger-config

In this case I can specify a complete path, but the webjars prefix does not work in the same way and does not solve my problem.

I have seen a similar issue here:
#24
But this user did not have an application context, but rather just a swagger context.

I have also seen this issue:
#1109
This user was able to fix the problem by having their proxy forward the X-Forwarded-Prefix header. Unfortunately I do not have any control over my reverse proxy so this is not an option for me. I am deploying onto kubernetes and I can pass this header in using ingress rules. However, kubernetes ingress does not support variables, and I could only pass in a fixed value. Since my external context (dev, staging, prod) varies, this is not an option either.

Are there any other options for specifying the absolute path of my webjar file?

To Reproduce

  • What version of spring-boot you are using? 3.2.4
  • What modules and versions of springdoc-openapi are you using? 2.4.0

Expected behavior

I am looking for an option to specify the location of my webjars with an externally set context, that does not require me to update a reverse proxy.

@bnasslahsen
Copy link
Collaborator

@stuartkemp-e,

There is no plans for this.
The straight forward solution, is to configure well your reverse proxy.
See related docs:

@bnasslahsen bnasslahsen added the invalid This doesn't seem right label Jun 16, 2024
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

2 participants