Meteor http 只检索 headers 的一个子集

Meteor http get retrieving only a subset of headers

在我的 Meteor (1.2) 应用程序中,我通过 https 调用 client-side HTTP.get 到支持 CORS 的远程服务器。

var getUrl= "https://remoteserver/;
HTTP.call('GET', getUrl , {}, function (error, response) {
    console.log (response);
}

现在,问题是 set-cookie 字符串在响应的 HTTP header 中 存在 Chrome 的 DevTools 网络选项卡中的此类 HTTP 调用

然而,当我调用 console.log(响应)时,它们不包括在内。实际上只有这 3 个属性打印在 response['headers']:

深入挖掘后,我在 Meteor Docs 上发现

Cookies are deliberately excluded from the headers as they are a security risk for this transport. For details and alternatives, see the SockJS documentation.

现在,在链接 SockJS docs 上,它说

Basically - cookies are not suited for SockJS model. If you want to authorise a session - provide a unique token on a page, send it as a first thing over SockJS connection and validate it on the server side. In essence, this is how cookies work.

我发现这个 this answer 关于 sockJS,但它看起来已经过时并且不是 Meteor 特有的。

远程服务器希望我使用cookie-setheader,所以我别无选择。此外,出于已确定的可扩展性原因,HTTP.call 必须完成 client-side(server-side 根本不是问题) 我可以采用什么解决方案/解决方法?

这个包看起来是为了帮​​助解决这种情况而设计的,虽然我没有使用过它:

https://atmospherejs.com/dandv/http-more