Local PostgREST returns PGRST301 (Invalid JWT parts) when createClient sb_secret/sb_publish
What I’m trying to do
But stopped working after I nuked my local environment and started from scratch.
CODE:
Tried different variations but for whatever reason it errors out.
Hot to get JWT tokens from Supabase CLI?
SOLVED: by downgraded cli version to 2.39.2
- Run a local Supabase (via supabase CLI) and have a Node/Express backend query a table (projects) using @supabase/supabase-js.
- Verify health with a small script that does a simple select: id, updated_at from projects limit 1.
- The SDK initializes, but the REST query fails with:
- JWSError (CompactDecodeError Invalid number of parts: Expected 3 parts; got 1)
- Code: PGRST301
- This points to PostgREST rejecting the Authorization token (not a valid JWT).
- I’m using the new-style local keys supabase status prints: sbpublishable... and sbsecret...
- If these keys end up in Authorization: Bearer ..., the error occurs.
- OS: macOS
- Framework: Node/Express (backend)
- Library version:
- @supabase/supabase-js: ^2.57.1
- Running locally with supabase CLI (self-hosted dev)
supabase --version 2.45.5
But stopped working after I nuked my local environment and started from scratch.
CODE:
Tried different variations but for whatever reason it errors out.
Hot to get JWT tokens from Supabase CLI?
SOLVED: by downgraded cli version to 2.39.2