flask-cors
flask-cors copied to clipboard
Regex Subdmain Match
I have been trying for a long time to match a subdmain for CORS. I'm using Zeit Now's serverless service, which generates a random URL that always ends with wheatpaste.now.sh
, but can also work with the static domain staging.admin.wheatpaste.app
.
The static domain works perfectly, but the Now.sh doesn't.
Here's the list I've defined in a settings object:
CORS_ORIGINS='["https:\/\/(.)*\.wheatpaste\.now\.sh", "staging.admin.wheatpaste.app",]'
I tested using the regex tester and the URL https://wp-frontend-app-git-wp-168-events-frontend-setup.wheatpaste.now.sh
matches.
I've also tried 'now.sh'
, and 'wheatpaste.now.sh'
.
Any ideas what I'm doing wrong?
Thanks in advance!
Had this issue too. Chipping in for others who may find this later.
I was able to figure it out using the example given in #208 .
So the regex needed for the origin in OP's case would be: .*\.wheatpaste\.now\.sh
.
>>> import re
>>> re.match(".*\.wheatpaste\.now\.sh","https://wp-frontend-app-git-wp-168-events-frontend-setup.wheatpaste.now.sh")
<re.Match object; span=(0, 74), match='https://wp-frontend-app-git-wp-168-events-fronten>
>>>