我正在使用内部访问我的python Flask Web服务的Azure API管理。 Azure API适用于GET操作。对于POST,当我提出的jQuery AJAX调用,请求转换成选项和下面的错误显示出来Azure API管理中的CORS问题
No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://domain.com' is therefore not allowed access. The response had HTTP status code 500.
我加入了以下政策在Azure API,
<policies>
<inbound>
<cors>
<allowed-origins>
<origin>*</origin>
</allowed-origins>
<allowed-methods>
<method>*</method>
</allowed-methods>
<allowed-headers>
<header>*</header>
</allowed-headers>
</cors>
<base />
</inbound>
<outbound>
<base />
</outbound>
</policies>
但我仍我面临同样的问题。
同样的错误出现了,当我直接让AJAX POST请求到我的蟒蛇烧瓶服务,我固定它通过在烧瓶中加入以下代码,
@app.after_request
def after_request(response):
response.headers.add('Access-Control-Allow-Origin', '*')
response.headers.add('Access-Control-Allow-Headers', 'Content-Type,Authorization')
response.headers.add('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE')
return response
我应该在Azure的API管理改变让POST操作工作?
我最近也注意到了我的Azure api中的CORS故障,截至今天。这也是你最近的问题吗? – Haymaker87
我们也注意到了它们,从昨天开始。 – Brian
是的。最近的问题,浪费了一整天的时间。没有预料到来自微软 – Selva