-
-
Notifications
You must be signed in to change notification settings - Fork 753
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Doubt] Enable CORS with connexion #357
Comments
Hi @ernanirst - I believe you can access the underlying flask 'app' object and enable CORS the same way you'd do it with a flask service like so:
|
@ernanirst see #50 for answers/discussion, using |
Re-opening, as we should add a section regarding CORS on http://connexion.readthedocs.io/en/latest/cookbook.html |
See my PR #358. |
Thanks a lot, I've tried something very similar which did not work, but this worked fine. I suggest that you add this to the docs because I looked there and found nothing. Thanks again. |
I'm trying to use flask cors with connexion
Yet when I send a request
I get
|
Just a stab in the dark. But add the ...
CORS_RESOURCES = {r"/v1/*": {"origins": "*"}, r"/v1.0/*": {"origins": "*"}, r"/v1.1/*": {"origins": "*"}}
CORS(app.app, resources=CORS_RESOURCES)
... |
Seems |
Just for reference, for simple use cases you can simply add the required headers yourself to all responses. There is two ways to achieve this. Using a custom middleware:
Using Flask's after_request hook:
While the |
Description
I have a static file with some jQuery that access an API built with connexion. Unfortunatelly, the browser requires CORS to be enable in order to access the API. I couldn't find a way of adding fields to the headers response nor a module or option to do that, so I'm not sure on what to do about.
Additional info:
Another possible workaround would be if I could just serve this static code with Connexion, I found lots of solutions for Flask but nothing that worked with Connexion
Output of the commands:
python --version
Python 3.4.3
The text was updated successfully, but these errors were encountered: