【发布时间】:2020-10-21 17:56:51
【问题描述】:
我在 django python 中有一个后端应用程序,它在 http://localhost:8000 上提供服务。
我有一个 Angular 前端,它在 http://localhost:4200 上提供服务。
我在 django 上禁用了 CORS。 在 http://localhost:8000/auth/login/ 上点击登录 api 时,我得到了有效的响应 连同 Set-Cookie 标头。
这是我打印 cookie 的 Angular 代码:
this.http.post<any>('http://localhost:8000/auth/login/', this.LoginForm, { observe: 'response' }).subscribe(response => {
console.log("response is ", response);
var cookies = this.cookieService.getAll();//('cookies');
console.log("cookies is :", cookies);
它在控制台上打印一个空对象。 我该如何进行这项工作?我想使用 cookie 进行身份验证。
【问题讨论】: