Add support for use '*' to allow CORS for all domains
This commit is contained in:
parent
0bba096775
commit
e0e0e57321
@ -162,11 +162,12 @@ class WebServer:
|
|||||||
webCorsOriginList.append(webCorsOrigin)
|
webCorsOriginList.append(webCorsOrigin)
|
||||||
|
|
||||||
corsOrigin = 'http://localhost'
|
corsOrigin = 'http://localhost'
|
||||||
if len(webCorsOriginList) == 1:
|
allowAllCors = '*' in webCorsOriginList # allow CORS for all domains
|
||||||
|
if len(webCorsOriginList) == 1 and not allowAllCors:
|
||||||
corsOrigin = webCorsOriginList[0]
|
corsOrigin = webCorsOriginList[0]
|
||||||
elif b'origin' in req.headers:
|
elif b'origin' in req.headers:
|
||||||
originStr = req.headers[b'origin'].decode()
|
originStr = req.headers[b'origin'].decode()
|
||||||
if originStr in webCorsOriginList:
|
if originStr in webCorsOriginList or allowAllCors:
|
||||||
corsOrigin = originStr
|
corsOrigin = originStr
|
||||||
|
|
||||||
headers = [
|
headers = [
|
||||||
|
Loading…
Reference in New Issue
Block a user