【发布时间】:2019-07-16 14:09:38
【问题描述】:
如何在 CORS 中启用多个选择的域?我可以看到 here 如何启用 CORS,但它要么是 * 卡,要么只是一个域。
我尝试了类似下面的方法,但没有成功
if request.method == 'OPTIONS':
# Allows GET requests from any origin with the Content-Type
# header and caches preflight response for an 3600s
# TODO: Restrict Origin
headers = {
'Access-Control-Allow-Origin': 'http://localhost:4200, http://localhost:8080',
'Access-Control-Allow-Methods': 'POST',
'Access-Control-Allow-Headers': 'Content-Type',
'Access-Control-Max-Age': '3600'
}
return ('', 204, headers)
# Set CORS headers for the main request
headers = {
'Access-Control-Allow-Origin': 'http://localhost:4200, http://localhost:8080'
}
return ('', 204, headers)
【问题讨论】:
标签: google-cloud-platform google-cloud-functions