Home > Mobile >  java Spring Boot with Swagger - Failed to load remote configuration
java Spring Boot with Swagger - Failed to load remote configuration

Time:04-13

I have a Java 11 Spring Boot 2.5.1 application.

Swagger works locally via http:

I have added Swagger, which works perfectly on my localhost:

http://localhost:8085/swagger-ui/index.html#/

enter image description here

Swagger does not work remotely via https:

However, when I deploy it to a remote server, I get the following error:

enter image description here

Error

Failed to load remote configuration.

note: the remote server is accessed via https.

The REST endpoints are accessible on the remote server.

e.g. GET enter image description here

{"configUrl":"/v3/api-docs/swagger-config","oauth2RedirectUrl":"http://localhost:8085/swagger-ui/oauth2-redirect.html","url":"/v3/api-docs","validatorUrl":""}

Remotely, there is a call to:

enter image description here

But https://mycompany.co/pow-wow/v3/api-docs/swagger-config

returns:

{"configUrl":"/v3/api-docs/swagger-config","oauth2RedirectUrl":"http://localhost:8085/swagger-ui/oauth2-redirect.html","url":"/v3/api-docs","validatorUrl":""}

So this suggests the issue is related to the /pow-wow context path is missing in the call.

CodePudding user response:

Try to add this as well to your security config class

@Override
public void configure(WebSecurity web) throws Exception {
   web.ignoring().antMatchers("/swagger-ui/**", "/v3/api-docs/**");
}

CodePudding user response:

You should try and add

springdoc:
  swagger-ui:
    config-url: /pow-wow/v3/api-docs/swagger-config
    url: /v3/api-docs

to your application.properties. In your provided example

https://mycompany.co/pow-wow/v3/api-docs/swagger-config

it shows that you have "/pow-wow/" in your path. Swagger needs to know where to fetch its config.

  • Related