corydolphin / flask-cors

Cross Origin Resource Sharing ( CORS ) support for Flask
https://flask-cors.readthedocs.io/en/latest/index.html
MIT License
889 stars 140 forks source link

support all subdomain of a domain when supports_credentials=True #208

Closed wobeng closed 7 years ago

wobeng commented 7 years ago

sorry for reopening. Just to confirm, I can add

https://..app.domain.com and https://..app.domain.com

in the origins list and it should work?

corydolphin commented 7 years ago

What do you mean "all subdomain"? If you want to support all subdomains under a root, e.g. api.domain.com, www.domain.com, all you need is ".*\.domain\.com"

The strings are matched using standard Python Regex, so to test, you can just run it in the repl:

import re

>>> re.match(".*\.domain\.com","example.domain.com", flags=re.IGNORECASE)
<_sre.SRE_Match object at 0x106037bf8>
>>> re.match(".*\.domain\.com","domain.com", flags=re.IGNORECASE)