Skip to content

Can't set JWT header #1290

Closed
Closed
@willsmanley

Description

@willsmanley

In the python SDK, I am able to set a JWT as a header that I already have to simulate a user request for RLS purposes:

anon_key = '123'
jwt = '123'
url = 'mysupabase.com' 
client_options = ClientOptions(headers={"apiKey": anon_key, "Authorization": f"Bearer {jwt}"})
supabase: Client = create_client(url, anon_key, client_options)

However in the JS SDK, the same thing doesn't work:

anon_key = '123'
jwt = '123'
url = 'mysupabase.com' 
const supabase = createClient(url, anon_key, {
    global: {
        headers: {"apiKey": anon_key, "Authorization": "Bearer " + jwt}
    }
});

The request still fires, but I get an empty response indicating that I did not pass the RLS policy of auth.uid() = user_id for the query

I'd love to help try to inspect how this actually results in different network requests, but not sure where to dig into.

Thank you for the amazing library!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions