简体   繁体   English

预检响应在axios中没有HTTP正常状态

[英]Response for preflight does not have HTTP ok status in axios

i am trying to add stations using open weather api and doing post request using axios 我正在尝试使用开放式天气api添加站点并使用axios进行发布请求

const stationData={
        external_id:this.state.external_id,
        name:this.state.name,
        latitude:this.state.latitude,
        longitude:this.state.longitude,
        altitude:this.state.altitude,
        }


    const url = `http://api.openweathermap.org/data/3.0/stations?appid=${ApiKey}`;

    var headers = {
        'Content-Type': 'application/json;charset=UTF-8', 
        "Access-Control-Allow-Origin": "*"
    }

    axios.post(url, data, {headers: headers}).then((response)=>{
console.log("response is " + response);
      }).catch((err)=>{
console.log("error is " + err);
      })

but it is giving me an error 但这给我一个错误

OPTIONS http://api.openweathermap.org/data/3.0/stations?APPID=2747592557924542516e283a7f905a81 404 (Not Found)

Failed to load http://api.openweathermap.org/data/3.0/stations?APPID=2747592557924542516e283a7f905a81: Response for preflight does not have HTTP ok status.

error is Error: Network Error

if i use the Postman to send the post request, its working there, any help please?? 如果我使用邮递员发送发帖请求,则该请求在那里工作,请提供任何帮助?

From Axios Git: Unfortunately, I think this boils down to one of the dreaded CORS issues that developers often face. 来自Axios Git: 不幸的是,我认为这可以归结为开发人员经常面临的可怕的CORS问题之一。 I could duplicate this and I tried a bunch of ways to poke at it to get the preflight request to work, but I couldn't find an opening in the server to let me through 我可以重复此操作,并尝试了多种方法来戳它,以使印前检查请求正常工作,但是我找不到服务器上的开口让我通过

Other useful links: cannot get cross-site POST to work , can not make post request ( cross domain ) . 其他有用的链接: 无法获得跨站点POST的工作无法发出发布请求(跨域) Basically it is a browser security issue rather than Axios. 基本上,这是浏览器安全问题,而不是Axios。 They are not planning to address that: either you choose another library or handle it from your backend. 他们不打算解决此问题:您选择另一个库或从后端处理它。 Note that with security disabled option in Chrome the request works. 请注意,在Chrome中禁用安全选项时,请求有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 CORS:对预检请求的响应未通过访问控制检查:它没有 HTTP 正常状态。 REACTJS, AXIOS - CORS: Response to preflight request doesn't pass access control check: It does not have HTTP ok status. REACTJS, AXIOS 如何允许 CORS 与 Flask 获得对预检请求的响应没有 http 正常状态 - How to allow CORS with Flask getting Response to preflight request does not have http ok status MVC Azure + AjaxCall + microsofttranslator +对预检请求的响应未通过访问控制检查:它没有HTTP ok状态 - MVC Azure + AjaxCall + microsofttranslator + Response to preflight request doesn't pass access control check: It does not have HTTP ok status 预检请求未通过访问控制检查:它没有 HTTP ok 状态 - Preflight request doesn't pass access control check: It does not have HTTP ok status CORS 错误:它没有 HTTP 正常状态 - CORS Error: It does not have HTTP ok status HTTP 正常状态 axios 上 javascript - HTTP ok STATUS axios on javascript React,Axios问题:预检响应具有无效的HTTP状态代码401 - React, Axios issue: Response for preflight has invalid HTTP status code 401 Cors 策略错误:它没有 HTTP 正常状态 - Cors Policity Error: It does not have HTTP ok status 预检的响应具有无效的HTTP状态代码400 - Response for preflight has invalid HTTP status code 400 预检的响应具有无效的HTTP状态代码405 - Response for preflight has invalid HTTP status code 405
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM