Reputation: 1916
in the picture swagger request use host and port,so browser console XMLHttpRequest cannot load http://115.159.22.159:9001/bp/api/v1/user/1. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://twogoods.cc' is therefore not allowed access.
how to solve it?
Upvotes: 4
Views: 9727
Reputation: 25942
You can use the host(..)
and protocols(..)
methods, to override the default values.
@Bean
public Docket customImplementation() {
return new Docket(DocumentationType.SWAGGER_2)
.protocols(Collections.singleton("https"))
.host("twogoods.cc")
.select()
.build();
}
Upvotes: 1
Reputation: 1916
@Bean
public Docket categoryApi() {
return new Docket(DocumentationType.SWAGGER_2)
.host("twogoods.cc")
.groupName("bookplatform-api")
.apiInfo(apiInfo())
.select()
.paths(apiPaths())
.build()
.directModelSubstitute(java.sql.Timestamp.class, java.sql.Date.class)
.enableUrlTemplating(false);
}
host()
method!!!
Upvotes: 3