javascript - httpclient 响应中不存在 Set-Cookie
问题描述
我正在尝试以角度创建登录页面并保存由我们的 Spring Boot 应用程序创建的 cookie
这就是我们在 BE 中创建 cookie 的方式
val cookie = createCookie(jwtProperties.cookieName, token, expirySeconds,
false, true, jwtProperties.cookieDomain, "/",
"sample comment")
response.addCookie(cookie)
response.status = HttpServletResponse.SC_OK
response.contentType = MediaType.APPLICATION_JSON_VALUE
response.writer.write(objectMapper.writeValueAsString(JwtGetDto(token)))
这是角度请求
const headers = new HttpHeaders({
'Content-Type': 'application/json'
});
const url = `${environment.api_url}/api/v1/auth/login`
return this._http.post(url, JSON.stringify({ username: username, password: password }), { observe: 'response', headers: headers});
这是浏览器中的响应
这是邮递员的回应
我试图添加withCredentials:true
角度请求,但仍然没有用
解决方案
推荐阅读
- javascript - 如何更新数组内列表中的项目?
- javascript - 如何将其转换为 Java,也许使用 Maps
- linux - Git 错误:gpg 未能在 Linux 上对数据进行签名
- ajax - react-native 获取请求失败
- c++ - 逐字节删除 void* 是否安全?
- javascript - 在 JQuery 的自定义队列中使用 .delay()
- assembly - 未抛出 x86 程序集标志标志
- c# - 不调用 Collision2D
- java - 使用多线程从正在写入的数组中安全读取
- ssas - 如何在 Analysis Services 中的每个层次结构级别上获取总数的百分比