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

Regex CORs #264

Closed
hmajid2301 opened this issue Dec 27, 2021 · 4 comments
Closed

Regex CORs #264

hmajid2301 opened this issue Dec 27, 2021 · 4 comments
Labels

Comments

@hmajid2301
Copy link

hmajid2301 commented Dec 27, 2021

Is your feature request related to a problem? Please describe.

Would it be possible to add regex CORs as an option, so we can support wildcard domains ?

Describe the solution you'd like

Perhaps you could specify another argument, something like so ?

socketio.AsyncServer(async_mode="asgi", regex_cors_allowed_origins=["http://localhost*:3000"])

Describe alternatives you've considered

Logs

Additional context

@miguelgrinberg
Copy link
Owner

The CORS specification does not support origins given as regular expressions.

@hmajid2301
Copy link
Author

Yeh sure, I know its not the same but FastAPI have their own implementation to support RegexCORs is there any appetite for this ? Or is there another way I can support wildcard domains.

Thanks

@miguelgrinberg
Copy link
Owner

miguelgrinberg commented Jan 11, 2022

How about this. Let's say the cors_allowed_origins option is extended to support a callable in addition to a string. When using this option, your function will be called to decide if an origin is allowed or not. Inside your function you can use anything you want to determine if you allow the origin, including a regex match.

@hmajid2301
Copy link
Author

yeh that sounds like a nice elegant "workaround". Thanks Miguel

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

No branches or pull requests

2 participants