Trying to create a socketio link between flask server and reactjs client. It shows this error
"Access to XMLHttpRequest at 'http://127.0.0.1:5000/socket.io/?EIO=3&transport=polling&t=MrcruFC' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource."
I have tried including CORS from the flask cors documentation but it still doesnot work.
Server:
from flask import Flask, Response
from flask_cors import CORS
from flask_socketio import SocketIO
app = Flask(__name__)
cors = CORS(app)
socketio=SocketIO(app)
@socketio.on('connection')
def handle_my_custom_event():
socket.emit('outgoing data',{num: '10'})
@app.route("/")
def hello():
return 'Hello'
if __name__ == '__main__':
socketio.run(app, host='0.0.0.0', port=5000)