go-socket.io icon indicating copy to clipboard operation
go-socket.io copied to clipboard

How to set CORS?

Open jvstatinydev opened this issue 2 years ago • 2 comments

Hello. I could archive CORS rule in python like this.

    app = Flask(__name__)
    origins = ["https://example.com", "https://www.example.com"]
    cors = CORS(app, resources={r"/*": {"origins": origins}})
    app.config['SECRET_KEY'] = 'secret!'
    socketio = SocketIO(app, async_mode="threading", cors_allowed_origins=origins)
    socketio.run(app, debug=False, allow_unsafe_werkzeug=True)

Is there an equivalent code in go-socket.io? This may sound dumb as I am new to go lang and go-socket.io. Thank you!

jvstatinydev avatar Feb 27 '23 08:02 jvstatinydev

@jvstatinydev Hey! is it code doesn't help to you?

sshaplygin avatar Feb 27 '23 10:02 sshaplygin

@sshaplygin Hello! Thank you for the example code. Could you let me know how to set CORS with this example? I want to allow one domain like I did in the python example that I wrote. I guess I should do something in "allowOriginFunc"?

jvstatinydev avatar Mar 01 '23 07:03 jvstatinydev