flask-cors icon indicating copy to clipboard operation
flask-cors copied to clipboard

Regex Subdmain Match

Open esfoobar opened this issue 5 years ago • 1 comments

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!

esfoobar avatar Apr 01 '19 17:04 esfoobar

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>
>>>

wangonya avatar Jul 27 '23 10:07 wangonya