Open TofPlay opened 5 years ago
Errors Hide Fetch errorFailed to fetch http://api.mycompany.com/swagger.json Fetch errorPossible cross-origin (CORS) issue? The URL origin (http://api.mycompany.com) does not match the page (http://swaggerui.mycompagny.com). Check the server returns the correct 'Access-Control-Allow-*' headers
@TofPlay Good morning. You need to allow CORS for api.mycompany.com. Without it you can't make requests from one subdomain to another.
Hey @TofPlay, first know that deploying Swagger UI and your API as separate services through Docker is a really popular thing to do! Let's try to figure out what's going on...
Questions:
RUN
block in your Dockerfile achieving? Just serving Swagger UI through Express with CORS?swagger.json
request? Check the Network tab as well.The problem with allowing CORS on the API is that it will not only be for Swagger UI. At the security level it's not the best.
@TofPlay you can manipulate Access-Control-Allow-Origin
to only allow your Swagger UI deployment to talk to your API, instead of sending back *
.
Q&A (please complete the following information)
Content & configuration
My dockerfile:
How can we help?
I'm trying to install Swagger-ui in a micro-services architecture Concretely it means that Swagger-ui is working in a container docker different from other services. The services are accessible via an url of the domain
api.mycompany.com
and Swagger-ui viaswaggerui.mycompagny.com
.The problem is that it generates me the error:
Here is what the API service returns when we make a request on the json:
What should I do for swagger-ui to work in a micro-services architecture knowing that each service can have its own sub-domain?