Supabase.js v2 Cannot read properties of undefined (reading 'getUser')
[Nest] 20112 - 21/01/2023, 09:58:12 ERROR [ExceptionsHandler] Cannot read properties of undefined (reading 'getUser')
TypeError: Cannot read properties of undefined (reading 'getUser')
at SupabaseStrategy.authenticate (...\node_modules\nestjs-supabase-auth\src\passport-supabase.strategy.ts:50:8)
at SupabaseStrategy.authenticate (...\dist\apps\api\webpack:\...\auth\strategies\supabase.strategy.ts:26:18)
at attempt (...\node_modules\passport\lib\middleware\authenticate.js:369:16)
at authenticate (...\node_modules\passport\lib\middleware\authenticate.js:370:7)
at ...\node_modules\@nestjs\passport\dist\auth.guard.js:96:3
at new Promise (<anonymous>)
at ...\node_modules\@nestjs\passport\dist\auth.guard.js:88:83
at SupabaseAuthGuard.<anonymous> (...\node_modules\@nestjs\passport\dist\auth.guard.js:49:36)
at Generator.next (<anonymous>)
at fulfilled (...\node_modules\@nestjs\passport\dist\auth.guard.js:17:58)
The culprit is this line:
this.supabase.auth.api <<<
.getUser(idToken)
The fix is:
this.supabase.auth <<<
.getUser(idToken)
Currently package "nestjs-supabase-auth": "1.0.9" works with:
@supabase/supabase-js": "^1.29.4
It doesn't work for:
"@supabase/supabase-js": "^2.4.1"
Will the repo be updated or will we have to fork our own since we can't do this if dockerizing
Any updates on this topic?
The problem seems to be here: passport-supabase.strategy
Hello everyone! Any updates on this topic? Very critical moment
Within this issue we can't create any Guard for protecting routes
Can you assign me the issue?
forked and merged at https://github.com/tgirotto/nestjs-supabase-auth-v2
@hiro1107 can you make another npm release? If I just run yarn add nestjs-supabase-auth - the release doesn't include this change.
Simple solution for solve this problem:
https://www.npmjs.com/package/patch-package
use patch-package lib and replace:
node_modules/nestjs-supabase-auth/dist/passport-supabase.strategy.js
this.supabase.auth.api.getUser(idToken)
to
this.supabase.auth.getUser(idToken)