【发布时间】:2021-06-16 19:12:31
【问题描述】:
您好,我正在使用 typescript 10+ 构建客户端 登录后,我收到一个带有 JSESSIONID 的 set-cookie,因为这是一个 HttpOnly true,所以我无法在浏览器中自动设置它,而且我希望这是自动化的
我需要在每次响应时将其设置为浏览器,并在每次来自服务器的请求时将其返回
logIn(restUserDTO: RestUserDTO): Observable<any> {
const haderParameters = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Access-Control-Allow-Headers': 'Content-Type',
'Authorization' :'BASIC '+ btoa(restUserDTO.username+":"+restUserDTO.password)
}
const haderOprions = {
headers:new HttpHeaders(haderParameters)
};
return this.http.post(constants.serverUrl+'api/rest/wout/login',null,haderOprions)
}
这是我用来登录我所缺少的东西的代码?
感谢您的宝贵时间
【问题讨论】:
-
是什么让你觉得cookie没有被浏览器自动发回?
-
嗨,我在应用程序选项卡上,在 cookie/域下没有设置任何内容