在请求标头Angular2中设置Cookie [英] Set Cookie in Request Headers Angular2

查看:314
本文介绍了在请求标头Angular2中设置Cookie的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是angular2的新手.我的服务器(弹簧)在其响应头中使用set-cookie值来响应认证.

I am new to angular2. My server(spring) responds authentication with a set-cookie value in its response headers.

如何将Cookie设置为下一个API调用的请求标头?

How to set that cookie to the request headers for the next API calls?

我搜索了很多,但是找不到合适的解决方案.

I searched a lot, but I cannot find a suitable solution.

推荐答案

Cookie将自动附加到您为域保存的每次呼叫中. 您做错了其他事.如果您想创建将身份验证数据附加到REST调用的自动机制,请参考创建自定义HttpInterceptor的本教程:

Cookies are automatically attached to every call you make after it i saved for your domain. You are doing something else wrong. In case you want to create automatic mechanism for attaching auth data to REST calls, refere to this tutorial that creates custom HttpInterceptor:

https://medium.com/aviabird/http-interceptor-angular2 -way-e57dc2842462

这篇关于在请求标头Angular2中设置Cookie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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