我有一个认证服务和一个api网关所有的api请求都是经过api网关的,问题是:我无法在身份验证服务中设置cookie。
@post('/signin')
signin(@Body() body:any,@Res({passthrough:true}) res:Response)
{
return this.appService.signin(body,res);
}这是我的api网关应用程序控制器。
signin(body,res)
{
const pattern = { cmd: 'signin' };
return this.clientServiceA.send<any>(pattern,{body,res})
}这是api网关的服务,这将向身份验证服务api发送请求
export class AppController {
@MessagePattern({ cmd: 'signin' })
signin(body,res) {
res.cookie('jwt',token,{httpOnly:true,expires:new Date(Date.now()+1000*60*60*24*7)});
// i cannot able to use res here it will throw an error
return {
status:200,
message:'login success'
}
}上面提到的代码是用于身份验证控制器的,我不能在那里使用res.cookies。我如何在这个服务中使用res.cookies?任何人都知道,请帮助我,我对微服务体系结构非常陌生。
发布于 2022-11-13 23:43:16
https://stackoverflow.com/questions/72882827
复制相似问题