0

我收到错误“消息”:“从 node.js 服务器调用 http 请求时找不到引用标头。

要求就像,首先我需要点击一个只接受 ajax 请求的框,然后路由到实际服务。

代码快照

var options = {
    url: 'http://' + fullpath,
    qs : params,
    headers : {
        Cookie : "COOKIE=" + my_cookie,
        Origin: 'http://my_url',
        "X-Requested-With": 'XMLHttpRequest'
    },
    encoding : null,

};


request.get(options, function (err, response, body) {

}

对上述错误有什么想法吗?

谢谢

4

1 回答 1

2

You're not passing a Referer header to request.get and apparently the server at http://[fullpath] expects it (perhaps as a sort of misguided form of security).

Try adding one:

headers : {
    Cookie : "COOKIE=" + my_cookie,
    Origin: 'http://my_url',
    "X-Requested-With": 'XMLHttpRequest',
    Referer : 'http://' + fullpath
},
于 2013-06-04T07:23:18.803 回答