【问题标题】:is it possible to make an authenticated request to a domain in node.js?是否可以向 node.js 中的域发出经过身份验证的请求?
【发布时间】:2013-03-07 03:19:24
【问题描述】:

我正在使用 node.js 和 request.js 模块来发出经过身份验证的 https 请求。

username = req.body.username;
password = req.body.password;
var url = 'https://' + username + ':' + password + '@domain.com';
request({
    url : url,
}, function (error, response, body){
  //do something here
});

是否有另一种方法可以做到这一点,而无需 node.js 服务器在不以纯文本形式公开密码的情况下进行此调用?

例如,假设我去了http://domain.com 并使用我的凭据登录。然后我可以关闭我的浏览器,重新访问 http://domain.com 并自动登录。然后我可以访问我的 node.js 应用程序 (localhost:3000) 并使用节点应用程序发出后续请求,而无需明确重新输入我的密码吗?

【问题讨论】:

    标签: node.js session cookies express httprequest


    【解决方案1】:

    不,您不能使用浏览器中的 cookie 登录 node。但是您可以像这样使用节点进行身份验证:How to use http.client in Node.js if there is basic authorization

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-05-23
      • 1970-01-01
      • 2012-04-24
      • 2016-05-01
      • 1970-01-01
      • 2019-03-29
      相关资源
      最近更新 更多