我正在从localhost进行RestApi调用,我收到了以下错误
XMLHttpRequest cannot load https://api-address/v1/registeruser.
No 'Access-Control-Allow-Origin' header is present on the
requested resource.Origin 'http://127.0.0.1:8887' is therefore not allowed access.
The response had HTTP status code 502.
然后我尝试修复此问题并将CORS扩展添加到我从SO获得的chrome。 添加扩展后我再次得到以下错误
POST https://api-address/v1/registeruser 502 (Proxy Error)
如何解决此问题?
答案 0 :(得分:0)
如果您使用Chrome,这可能与以下事实有关:它通过在GET / POST / PUT / DELETE之前发送OPTIONS来预检ajax请求,如下所述:
AJAX in Chrome sending OPTIONS instead of GET/POST/PUT/DELETE?
我建议确保您的REST服务器能够响应OPTIONS请求。