hi guys i want to use jwt on passwordless, i added...
# support-questions-legacy
u
hi guys i want to use jwt on passwordless, i added jwt:{enabled:true} to session.init. I want to use AuthGuard and session decorator. i followed nestjs guide. But when i call some api i got error. Error: Cannot set headers after they are sent to the client AuthGuard @Injectable() export class AuthGuard implements CanActivate { async canActivate(context: ExecutionContext): Promise { const ctx = context.switchToHttp(); let err = undefined; const resp = ctx.getResponse(); await verifySession()(ctx.getRequest(), resp, (res) => { err = res; }); if (resp.headersSent) { throw new STError({ message: 'RESPONSE_SENT', type: 'RESPONSE_SENT', }); } if (err) { throw err; } return true; } }
r
@porcellus can help with this.
p
hi
I'll check this out in a sec. what version of the SDK are you using?
u
@porcellus "supertokens-node": "^11.1.0",
p
hmm, and are you using graphql or is this in a normal REST API?
u
@porcellus no
normal rest api
p
is it working ok without jwt? or could you show more of your code? this should be working :/
it'd be easiest if I could get a copy (or access to) the repo. btw, do you get any further logs from the error? a stacktrace maybe?
u
sorry i solved issue
my mistake
thank you
r
Thank you @porcellus
What was the mistake?
u
i forgot to add app.useGlobalFilters(new SupertokensExceptionFilter());
in main.ts
r
Cool! Glad to know it worked 🙂
2 Views