Nodejs请求模块不发送授权头 [英] Nodejs request module doesn't send Authorization header

查看:483
本文介绍了Nodejs请求模块不发送授权头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在https网址上发送带有授权标头的GET请求。我尝试使用以下代码执行此操作:

I need to send GET request on https url with "Authorization" header. I try to do this using this code:

request.get({
  url: url,
  headers: {
    'Authorization': token,
    'abc': 'def'
  }
})

在服务器端,我得到abc标头,但没有授权标头。为什么会这样?

On server side I get "abc" header, but there is no Authorization header. Why does it happen?

推荐答案

您是否尝试过使用 auth 键?请参阅项目自述文件中的详细信息示例

请求.get('http://some.server.com/', {
'auth':{
'user':'username',
'pass':'password',
'sendImmediately':false
}
});

Have you tried using auth key? See the details example in the project's readme request.get('http://some.server.com/', { 'auth': { 'user': 'username', 'pass': 'password', 'sendImmediately': false } });

这篇关于Nodejs请求模块不发送授权头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆