我正在尝试创建一个角度登录页面并保存由我们的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
,但仍然没有成功