Hi I am getting this error :
Using nest js for creating jwt for user
here is my middleware :
`@Injectable()
export class HoichoiUserAuthMiddleware implements NestMiddleware {
supertokensMiddleware: any;
constructor(
.... ) {
this.supertokensMiddleware = middleware();
}
async use(req: any, res: Response, next: () => void) {
if (req.headers['anonymous-token']) {
console.log('direct passage');
return this.supertokensMiddleware(req, res, next);
}
console.log('indirect passaf');
const clientIp = requestIp.getClientIp(req);
let ipInfo = null;
try {
// hardcoded for local testing
ipInfo = await this.geoLocatorHelper.getLocationInfoFromIpAddress('114.134.26.87');
} catch {
// to be discussed
throw new BadRequestException('ip info not found');
}
const anonymousSessionDto = new AnonymousSessionDto();
anonymousSessionDto.ipInfo = ipInfo;
// anonymousSessionDto.userId = `G-${this.uuidHelper.generateId()}`;
const jwtToken: string = await this.jwtService.signAsync({
anonymouseSessionDto: anonymousSessionDto,
});
req.headers['anonymous-token'] = jwtToken;
return this.supertokensMiddleware(req, res, next);
}
}`
Here is supertoken service session method :