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

Update PostgrestClient.ts to allow for additional headers on-demand #550

Merged
merged 1 commit into from
Aug 3, 2024

Conversation

activenode
Copy link

What kind of change does this PR introduce?

Feature

What is the current behavior?

Currently you cannot use the postgrest-js to add additional headers which however is required in use-cases such as described in https://supabase.com/docs/guides/api/securing-your-api?queryGroups=database-method&database-method=sql&queryGroups=pre-request&pre-request=rate-limit-per-ip

What is the new behavior?

One can pass additionalHeaders and does not have to build a custom wrapper.

@soedirgo
Copy link
Member

Thanks! Does the headers option in the PostgrestClient constructor not work for this?

@activenode
Copy link
Author

The problem is that it's global. But headers are dynamic. Mapped back to the sample provided it would mean that, for each change, I'd have to instantiate a new Supabase-js client (using the underlying Postgres client)

@soedirgo
Copy link
Member

Makes sense, thanks! How about a setHeader() method in PostgrestBuilder? That allows you to use it more generically, e.g. with .from().

@activenode
Copy link
Author

that sounds great

@activenode
Copy link
Author

shall I go for it?

@soedirgo
Copy link
Member

Hey! Went ahead and updated the PR - if you can verify this works for your use case I'll go ahead and merge this 👍

@activenode
Copy link
Author

Wow, great! Will do.

@activenode
Copy link
Author

image tested both rpc and select, works damn fine.

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.

Awesome! Merging now 🚀

@soedirgo soedirgo merged commit 9f91e72 into supabase:master Aug 3, 2024
1 check passed
Copy link

github-actions bot commented Aug 3, 2024

🎉 This PR is included in version 1.16.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants