Hello ,
I am trying to connect from my localhost to a virtual machine via sockets, it worked before with another vm. But now its telling me its blocked by CORS policy below is a screenshot

I am running my code as follows:
socketio.run(app, host='0.0.0.0', port=443,ssl_context=...
the certificate of the vm is imported and added to the certificate manager.
The current release of Flask-SocketIO has stricter requirements with regards to cross-origin requests. See the documentation on the cors_allowed_origins option for more information. In your situation I think adding cors_allowed_origins='https://localhost' will resolve the error.
Do you mean adding this parameter to the socketio.run (…)
or to the io.connect at the client side ?
Sorry to bother
SocketIO(app,cors_allowed_origins="*")
this works for me.
@mrxmamun that works but leaves you exposed to potential CSRF attacks, so use at your own risk.
@aat4 this is an option when you create your SocketIO object. Check the documentation if in doubt.
I'm trying to connect to the flask server from a react app. Flask app and client running on localhost. React app running on port 3000, Flask app on 5000. I'm using this and still nothing:
socketio = SocketIO(app,cors_allowed_origins="*")
Any ideas? is https://www.npmjs.com/package/socket.io incompatible? something in node / react?
@swizzersweet do you have any additional components in your stack that could be altering the CORS headers after they are returned by this package?
@miguelgrinberg Following your guidance, I was able to fix it. I ended destroying and reinstalling all the dependencies, and now my ReactJS app can connect properly. I likely installed something that interfered somehow. 🤷