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

fix: passing authtoken only in http request #121

Merged
merged 2 commits into from
Nov 25, 2024

Conversation

pffigueiredo
Copy link
Contributor

Description

This PR aims to fix an ongoing bug that made passing the authToken property only on the sql function lead to an error.

BUG

Passing just the authToken in the callback function would lead to an HTTP request to the "regular" API endpoint , instead of pointing to the Proxy one.

e.g. the following snippet would lead to an authentication error, because we don't pass the authToken in the neon connection setup function.

const db = drizzle(neon(process.env.NEXT_PUBLIC_DATABASE_AUTHENTICATED_URL!), {
  schema,
});
const token = await auth.getToken();
// this would error, because we didn't pass the token on top
const todos = db.$withAuth(token!).select().from(schema.todos);

Test Plan

Tested this manually:

httpOnlyAuthTOkenFix.mp4

@pffigueiredo pffigueiredo force-pushed the fix-only-passing-authtoken branch from c50ed4e to 041ca30 Compare November 25, 2024 12:52
@pffigueiredo pffigueiredo merged commit d81bd41 into main Nov 25, 2024
4 checks passed
@pffigueiredo pffigueiredo deleted the fix-only-passing-authtoken branch November 25, 2024 12:55
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.

2 participants