Skip to content

Static javascript and css not serving #649

@airam85

Description

@airam85

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?

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