Skip to content

How can I fix swagger.json request blocked due to CORS with docker-compose/gunicorn/nginx stack? #221

Description

@steg87

I am trying to deploy a Flask REST app with Flask-RestX autogenerating Swagger UI for it. The development versions work fine on localhost, but I think something about the reverse proxy is throwing it.

I am getting the following error message when I try to access the Swagger API page in the docker-compose/gunicorn/nginx deployment;

"Failed to load API definition.

Errors

Fetch error NetworkError when attempting to fetch resource. http://127.0.0.1/swagger.json Fetch error Possible cross-origin (CORS) issue? The URL origin (http://127.0.0.1) does not match the page (http://127.0.0.1:4000). Check the server returns the correct 'Access-Control-Allow-*' headers."

I've recreated the error using the Flask-RestX Hello World Todo app, git@github.com:stevengillies87/flask-restx-docker-deploy.git

Since the error mentions CORS I tried adding the flask-cors package, which you can see on the flask-cors branch of the repo. It made no difference.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions