@Post("local")
@UseGuards(LocalAuthGuard)
async localLogin(
@Req() request: Request,
@Res({ passthrough: true }) response: Response
) {
const jwt = await this.authService.localLogin(request.body);
response.cookie("access_token", jwt, {
maxAge: 3600000,
sameSite: true,
//enable to secure with https
secure: false,
});
}
I want to set the cookies in the browser through the response.
However, I this does not seem to work. Nothing happens.
Also if I remove response.send({}) it throws an error: Error: SyntaxError: Unexpected end of JSON input, as if it is expecting a response object. However according to the NestJs docs @Res({ passthrough: true }) allows you to only set the cookie.
