Forward convexUrl to Next.js Convex helpers#359
Conversation
|
@JohnKesko is attempting to deploy a commit to the Convex Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Pull request overview
This PR ensures the configured convexUrl is forwarded into the Convex Next.js helper calls made by the authenticated Better Auth wrappers, and adds a regression test to prevent future regressions.
Changes:
- Forward
opts.convexUrlintopreloadQuery,fetchQuery,fetchMutation, andfetchActionvia the options object. - Update internal helper typing to include the
urloption alongsidetoken. - Add a Vitest regression test verifying
urlis passed for all authenticated Next.js helper wrappers.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/nextjs/index.ts | Threads opts.convexUrl through to Convex Next.js helper options ({ token, url }). |
| src/nextjs/index.test.ts | Adds a regression test asserting all authenticated wrappers pass url (and token) to Convex helpers. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: get-convex/coderabbit/.coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe changes update the Convex integration to forward the Convex URL alongside the authentication token through all query, mutation, and action calls. A corresponding test suite was added to verify that the Suggested reviewers
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.Comment |
|
@JohnKesko you can access your Convex site url via |
|
Yes, The bit I ran into was the separate Convex client/deployment URL.
Because of that, those helpers fall back to For example, my setup looks roughly like this: import { convexBetterAuthNextJs } from "@convex-dev/better-auth/nextjs";
if (!process.env.NEXT_PUBLIC_CLIENT_URL) {
throw new Error("NEXT_PUBLIC_CLIENT_URL environment variable is not set");
}
if (!process.env.NEXT_PUBLIC_API_URL) {
throw new Error("NEXT_PUBLIC_API_URL environment variable is not set");
}
export const {
handler,
preloadAuthQuery,
isAuthenticated,
getToken,
fetchAuthQuery,
fetchAuthMutation,
fetchAuthAction,
} = convexBetterAuthNextJs({
convexUrl: process.env.NEXT_PUBLIC_CLIENT_URL, // .convex.cloud, this is what the PR passes through
convexSiteUrl: process.env.NEXT_PUBLIC_API_URL, // .convex.site, already used by the auth handler
}); |
|
@erquhart Is this something you will consider? |
Summary
convexUrlintopreloadQuery,fetchQuery,fetchMutation, andfetchActionfrom the Next.js auth helperVerification
npm run test -- src/nextjs/index.test.tsnpm run build