Skip to content

Static javascript and css not serving #649

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
airam85 opened this issue May 5, 2020 · 3 comments
Closed

Static javascript and css not serving #649

airam85 opened this issue May 5, 2020 · 3 comments

Comments

@airam85
Copy link

airam85 commented May 5, 2020

We have a Java Spring Boot application running 2.2.5.RELEASE.
We are using springdoc-openapi-ui and springdoc-openapi-security version 1.3.0 (also tried 1.3.6). Ingress Nginx configured with the x-forwarded-prefix annotation (as seen in this isue):
nginx.ingress.kubernetes.io/x-forwarded-prefix: "true"

We have tried both the yaml:

server.use-forward-headers: true
server.forward-headers-strategy: framework

And the bean:

@Bean
ForwardedHeaderFilter forwardedHeaderFilter() {
        return new ForwardedHeaderFilter();
} 

The issue is, with this configuration the index.html gets served, but the .js and .css don't because the paths are relative and the context path is not used. What I mean is, since our server is:
http://server/context-path/swagger-ui.html
This redirects to http://server/context-path/swagger-ui/index.html?configUrl=/context-path/v3/api-docs/swagger-config
The index.html gets served, but as the code is:
<script src="./swagger-ui-bundle.js"> </script>
The URL of this js loaded is
http://server/context-path/swagger-ui-bundle.js
Which gets a 404 since the js is actually in
http://server/context-path/swagger-ui/swagger-ui-bundle.js
You can see this in this screen capture:
image

Is there any configuration so the static files load from the correct path?

@bnasslahsen
Copy link
Collaborator

@airam85,

There is no static files configuration required. And there is no known issue about your description.

You can have a look at the answer here: #607

You should just make sure, all the steps described here are respected:

@airam85
Copy link
Author

airam85 commented May 6, 2020

I've found a similar issue here: 215

To my knowledge, I've already put all those options and tried to explained it in the issue.

@bnasslahsen
Copy link
Collaborator

Its the only necessary settings on springdoc-openapi side.
If you are still having issues, you should revisit your infrastructure configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants