Angular 2 Http请求不发送凭据
发布时间:2020-12-17 17:41:23 所属栏目:安全 来源:网络整理
导读:我正在使用Angular 2,我正在尝试使用凭据发送HTTP请求: 这个Angular 1代码运行良好,它包含凭据: $http.get("http://some.com/user",{ withCredentials: true}) 根据API预览,我已经实现了这个Angular 2代码,但它不包含凭据: http.get("http://some.com/use
|
我正在使用Angular 2,我正在尝试使用凭据发送HTTP请求:
这个Angular 1代码运行良好,它包含凭据: $http.get("http://some.com/user",{ withCredentials: true})
根据API预览,我已经实现了这个Angular 2代码,但它不包含凭据: http.get("http://some.com/user",{
headers: myHeaders,credentials: RequestCredentialsOpts.Include
}).toRx()
.map(res => res.json())
.subscribe(
// onNext callback
data => this.successHandler(data),// onError callback
err => this.failure(err)
);
我正在使用Angular 2.0.0-alpha.37. 解决方法
我正在使用angular2@2.0.0-alpha.37;
如果在xhr_backed.js中添加代码,则可以将“凭据”发送到服务器 this._xhr.withCredentials = true; angular2@2.0.0-alpha.37/src/http/backends/xhr_backed.js var XHRConnection = (function() {
function XHRConnection(req,browserXHR,baseResponSEOptions) {
........
this._xhr = browserXHR.build();
this._xhr.withCredentials = true;
........
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
