Flask-socketio - Failed To Set "Access-Control-Allow-Origin" Response Header
I wrote this simple flask-socketio code: from flask import Flask from flask_socketio import SocketIO, send app = Flask(__name__) app.config['SECRET_KEY'] = 'mysecret' socketio =
Solution 1:
Below solve it for me. Interaction from Angular app.
socketio = SocketIO(app, cors_allowed_origins="*")
Solution 2:
Cross origin is enabled by default on Flask-SocketIO. My guess is that the way you are testing this is flawed. While running your example application, I can send a request to the main Socket.IO endpoint and I do get the Access-Control-Allow-Origin
header in the response:
~ $ http http://localhost:5000/socket.io/
HTTP/1.1 200 OK
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 119
Content-Type: application/octet-stream
Date: Fri, 01 Jun 2018 17:10:01 GMT
Set-Cookie: io=dd8d67788df54510830fea64bc82b1fd
+-----------------------------------------+
| NOTE: binary data not shown in terminal |
+-----------------------------------------+
Post a Comment for "Flask-socketio - Failed To Set "Access-Control-Allow-Origin" Response Header"