Reputation: 287
How can I return my generated authentication token from my NestJS Rest API initial Route to the Frontend using the Response Header.
I have my AuthController that receives the request to validate the user and then return the Authentication token using Nest JWT. And for security reasons I want to return this Token in the Header of the response, but how can I return this value generated in my service to the response object?
@Get()
async auth(
@Req() req: Request)
) {
const userData = await this.appService.login(req);
userData.token?? // How to return this in the response header object?
return userData;
}
Upvotes: 0
Views: 95