Skip to content Skip to sidebar Skip to footer

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:

~$httphttp://localhost:5000/socket.io/HTTP/1.1200OKAccess-Control-Allow-Credentials:trueAccess-Control-Allow-Origin:*Connection:keep-aliveContent-Length:119Content-Type:application/octet-streamDate:Fri,01Jun2018 17:10:01 GMTSet-Cookie:io=dd8d67788df54510830fea64bc82b1fd+-----------------------------------------+|NOTE:binarydatanotshowninterminal|+-----------------------------------------+

Post a Comment for "Flask-socketio - Failed To Set "access-control-allow-origin" Response Header"