【问题标题】:angularjs Response for preflight has invalid HTTP status code 404 [duplicate]预检的angularjs响应具有无效的HTTP状态代码404 [重复]
【发布时间】:2018-03-12 12:53:52
【问题描述】:

source code 当我从邮递员 POST 数据时,它显示正确的响应数据, 但是当我使用应用程序(客户端)端发布数据时,它显示加载失败http://localhost:3000/done:预检响应具有无效的 HTTP 状态代码 404

【问题讨论】:

    标签: javascript angularjs ionic-framework cors mean


    【解决方案1】:

    在发布数据时,你的本地服务器(意味着后端服务器应该是开启的),并通过 Header、queryparam 或 body 发布数据,

    并确保您在后端收到相同的参数,

     $http.post('http://localhost:9191/api/signin', {
        username: 'some username',
        password: 'some password'
      }, {
        headers: {
          'Content-Type': 'application/x-www-form-urlencoded',
          'key': '123'
        }
      })
      .then(function(response) {
        console.log(response)
      });
    

    并且不要对数据对象使用json.stringify,现在只发送对象。

    【讨论】:

    • 全部设置正确。bt 它显示了预检响应
    • 你能把代码分享给我们吗??
    • 是的,我补充说
    • 确保你写的是“application/json”
    • 检查一下,我已经为你添加了代码。
    猜你喜欢
    • 1970-01-01
    • 2017-09-26
    • 2016-02-13
    • 2018-04-25
    • 2016-10-10
    • 2016-01-22
    • 2017-12-22
    • 2016-10-28
    • 2018-04-11
    相关资源
    最近更新 更多