Hello,
I'm currently facing an issue while working with NestJS, Passport-JWT, and Supabase. Here's how my workflow unfolds: I initiate requests from my frontend, including an access token obtained from Supabase, which is included in the authorization header with the format "Bearer: ...".
This is my strategy:
@Injectable()
export class SupabaseStrategy extends PassportStrategy(Strategy) {
constructor(configService: ConfigService) {
super({
jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(),
ignoreExpiration: false,
secretOrKey: configService.get('SUPABASE_JWT_SECRET'),
});
}
async validate() {
Promise.resolve(true);
}
authenticate(req: Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>, options?: any): boolean {
return true
}
}
This is my guard:
@Injectable()
export class SupabaseGuard extends AuthGuard('jwt') {}
And this my module, which is imported into the app.module.ts:
@Module({
imports: [
PassportModule,
JwtModule.registerAsync({
imports: [ConfigModule],
useFactory: async (configService: ConfigService) => {
return {
secret: configService.get<string>('SUPABASE_JWT_SECRET')
}
},
inject: [ConfigService]
}),
],
providers: [SupabaseService, SupabaseStrategy],
exports: [SupabaseService, JwtModule, PassportModule]
})
export class SupabaseModule { }
If I currently send requests to an endpoint that utilizes the @UseGuards(SupabaseGuard) decorator, the requests appear to hang in a "pending" state indefinitely. I've followed the documentation on nestjs.com, but I'm unsure where I may have gone wrong.
Could someone please provide some assistance or guidance to help resolve this issue?