【发布时间】:2017-08-27 06:20:53
【问题描述】:
我是这样使用http的:
private headers = new Headers({ 'Content-Type': 'application/json' })
login(loginUser: LoginUser): Promise<User> {
return this.http.post('http://localhost:9009/api/users/login', JSON.stringify(loginUser), { headers: this.headers })
.toPromise()
.then(res => res.json())
.catch(this.handleError)
}
这应该会自动设置cookie到浏览器,像这样:
但是浏览器中没有设置cookie。
- Angular 版本:2.4.10
- 浏览器:Chrome 56.0.2924.87(64 位)| FireFox 52.0.2(64 位)
- 语言:TypeScript 2.2.1
- 节点(针对 AoT 问题):node --version = 3.10.10
响应头:
【问题讨论】:
-
没有烤饼干。
-
谢谢,我通过设置 withCredentials=true 解决了这个问题