Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling CORS with Wildcard Subdomains in Flask-SocketIO #2086

Open
martenzo7 opened this issue Aug 13, 2024 · 1 comment
Open

Handling CORS with Wildcard Subdomains in Flask-SocketIO #2086

martenzo7 opened this issue Aug 13, 2024 · 1 comment
Assignees

Comments

@martenzo7
Copy link

Hi,

I'm trying to configure Flask-SocketIO to handle CORS for multiple subdomains (e.g., cors_allowed_origins='*.domain.com').

allowed_origins = [
    'https://*.domain.com',
    'http://*.localdomain.com'
]

socketio = SocketIO(app, cors_allowed_origins=allowed_origins)

However, I noticed that cors_allowed_origins does not support wildcards directly. unless it's from all domains (e.g., cors_allowed_origins='*'). I know I could make a list for all my subdomains but that would take so long since I created a lot of subdomains.

Could you please advise on the best approach to handle CORS with wildcard subdomains for Socket.IO? Is there a recommended way to configure this or any workarounds?

Thanks in advance!

@miguelgrinberg
Copy link
Owner

CORS with wildcards is not directly supported by the CORS specification, so it has to be implemented as a server-side extension. Unfortunately this is not available in the CORS support that Flask-SocketIO uses at this time, so the options are all domains, or an explicit list of them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants