Home Access-Control-Allow-Origin error with AngularJS and Flask-Socketio
Reply: 0

Access-Control-Allow-Origin error with AngularJS and Flask-Socketio

user1165 Published in May 27, 2018, 3:38 am

I am trying to make Flask-Socketio connection from AngularJS at client side to a Flask server.

Connecting with the Flask server works fine, but when I try to connect to socketio in my Angular controller:

var socket = io.connect('http://localhost:5000');

I see the following error on my browser console:

Failed to load http://localhost:5000/socket.io/?EIO=3&transport=polling&t=1526477253000-2: The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. Origin 'http://localhost:3000' is therefore not allowed access. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.

My client side (AngularJS) is running on port 3000 (gulp) and Flask server is running on port 5000.

I have tried including flask_cors with:

cors = CORS(app, resources={r"/*": {"origins": "*"}})

But still get the same issue.

Any help is appreciated. Cheers.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.30849 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO