I have two microservices (Transactions and Payments) that are gonna be accessed through an ApiGateway, and each microservice is inside a docker container. Also, I have implemented my own SwaggerResourcesProvider in order to access both Swagger from a single point: the ApiGateway Swagger, as you can see in this question: Single Swagger
In order to enable CORS in each microservice, all of them (including ApiGateway) have the following code:
@Bean
public CorsFilter corsFilter() {
final UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
CorsConfiguration config = new CorsConfiguration();
config.setAllowCredentials(true);
config.addAllowedOrigin("*");
config.addAllowedHeader("*");
config.addAllowedMethod("*");
source.registerCorsConfiguration("/**", config);
return new CorsFilter(source);
}
If I execute each microservice using the IDE, I can access Swagger of microservices from the ApiGateway without any problem, as you can see here (ApiGateway is executed on 8070 port):
However, when I execute them using docker-compose, and I try to access Swagger of any microservice through ApiGateway (mapping internal port to 8070), I am receiving the following error:
The weird thing is that, if I enter inside the ApiGateway docker using bash, and I execute curl transactionservice/api/v2/api-docs then I am receiving the corresponding json, so docker of ApiGateway is accessing to the Swagger of the rest of the dockers, but it is not able to access from my web browser.
Question: Why Swagger is unable to access other Swaggers when being executed using docker?