TUS Resumable Uploads + Clerk JWT returning 403 RLS error
Need help: TUS resumable uploads with Clerk JWT getting 403 RLS error
Running into a persistent issue with resumable uploads using Clerk third-party auth. Would appreciate any guidance.
Setup:
Problem:
Questions:
Running into a persistent issue with resumable uploads using Clerk third-party auth. Would appreciate any guidance.
Setup:
- Next.js 15 + Clerk for authentication
- Supabase Storage with TUS protocol for resumable uploads
- Clerk configured as third-party provider (Dashboard → Auth → Third-Party)
- Using direct storage endpoint:
https://<project-id>.storage.supabase.co/storage/v1/upload/resumable
Problem:
- TUS POST returns
403 new row violates row-level security policy - Storage auth test works (can list buckets with same Bearer token → returns 200)
- Small file uploads via service_role work fine
- Storage policies use
requesting_user_id()which callsconvert_to_uuid(auth.jwt()->>'sub')
Questions:
- Does the Bearer token from
Clerk.session.getToken()have the right format for Supabase Storage RLS? - Should I be using a different Clerk token method or template?
- Is there a way to debug what
requesting_user_id()returns during the Storage RLS evaluation?
JWKS endpoint is accessible
Storage auth test passes (listBuckets returns 200)
JWT has
sub,iss,role: "authenticated",expUser exists in project_members with proper role
TUS POST to
/storage/v1/upload/resumable→ 403 RLS