googollee / go-socket.io

socket.io library for golang, a realtime application framework.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to set CORS?

jvstatinydev opened this issue · 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 Hey! is it code doesn't help to you?

@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"?