【发布时间】:2017-02-19 00:43:38
【问题描述】:
我正在尝试在我的 API 上支持跨域资源共享 (CORS) 调用,该 API 使用 Python 中的 Google Cloud Endpoints Framework v2 编写,但我无法做到。
根据the documentation,默认情况下启用了CORS,但我无法使用Javascript从不同的来源进行任何调用,我明白了:
XMLHttpRequest 无法加载 https://myapp.appspot.com/_ah/api/apiname/v1/events。对预检请求的响应未通过访问控制检查:请求的资源上不存在“Access-Control-Allow-Origin”标头。因此,Origin 'http://fiddle.jshell.net' 不允许访问。响应的 HTTP 状态代码为 500。
我尝试像this SO question 那样添加 response.headers,但它也不起作用。
有谁知道如何在我的 API 中启用 CORS?
谢谢!
【问题讨论】:
-
嗨,这个问题你解决了吗?
标签: google-app-engine google-cloud-endpoints