Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use custom headers in every client #311

Merged
merged 1 commit into from Nov 26, 2021

Conversation

mgm1313
Copy link
Contributor

@mgm1313 mgm1313 commented Nov 25, 2021

What kind of change does this PR introduce?

Feature

What is the current behavior?

Since #218 custom headers passed to the SupabaseClient constructor are passed on to the GoTrueClient.
However they are not passed on to thePostgestClient, SupabaseStorageClient and SupabaseQueryBuilder, although implied by the param description:

* @param options.headers Any additional headers to send with each network request.

What is the new behavior?

Headers passed through the options.headers parameter of the constructor are now stored in a new protected variable headers. Since all clients mentioned above call the private method _getAuthHeaders I decided to inject the custom headers here, together with the default headers that were already injected inside this method.

Additional context

I also created a very minimal test case, just to be sure the _getAuthHeaders method indeed returns the custom headers. I'm not an expert on Jest, so as far as convention goes there might be more optimal ways to test the functionality this PR introduces.
Closes #166

Copy link
Member

@soedirgo soedirgo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @mgm1313!

@soedirgo soedirgo merged commit d3438c9 into supabase:master Nov 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Headers provided to Supabase client are not used in requests
2 participants