Skip to content

Sync Convex Better Auth fixes and support Better Auth 1.6.5#217

Merged
zbeyens merged 17 commits into
mainfrom
codex/sync-convex-auth-0-11-4
Apr 17, 2026
Merged

Sync Convex Better Auth fixes and support Better Auth 1.6.5#217
zbeyens merged 17 commits into
mainfrom
codex/sync-convex-auth-0-11-4

Conversation

@zbeyens
Copy link
Copy Markdown
Member

@zbeyens zbeyens commented Apr 16, 2026

Summary

  • add the sync-convex-auth audit skill for fork/upstream review work
  • bump @convex-dev/better-auth to 0.11.4
  • make registerRoutes lazy by default and require explicit basePath for non-default auth routes
  • support better-auth@1.6.5 across kitcn, example, docs, and auth fixtures
  • add local structural wrappers around Convex Better Auth plugin/client surfaces so Better Auth 1.6.x compiles before upstream catches up
  • fix auth adapter composite index matching and accept Better Auth 1.6 Where.mode

Breaking changes

  1. Custom auth routes now need an explicit basePath when using registerRoutes.
  2. Supported Better Auth version moves from 1.5.3 to 1.6.5.
// Before
import { registerRoutes } from "kitcn/auth/http";

registerRoutes(http, getAuth, {
  cors: {
    allowedOrigins: [process.env.SITE_URL!],
  },
});

// After
import { registerRoutes } from "kitcn/auth/http";

registerRoutes(http, getAuth, {
  basePath: "/custom-auth",
  cors: {
    allowedOrigins: [process.env.SITE_URL!],
  },
});
# Before
bun add better-auth@1.5.3

# After
bun add better-auth@1.6.5

Notes

  • auth scaffold and runtime lanes still print Better Auth's upstream oidc-provider deprecation warning through @convex-dev/better-auth@0.11.4
  • the branch keeps the current published Convex Better Auth runtime and bypasses the stale type coupling locally inside kitcn

Verification

  • bun test packages/kitcn/src/cli/supported-dependencies.test.ts packages/kitcn/src/cli/registry/dependencies.test.ts
  • bun test packages/kitcn/src/auth-client/package-entrypoints.integration.test.tsx packages/kitcn/src/react/auth-mutations.test.tsx
  • bun typecheck
  • bun run fixtures:sync
  • bun run fixtures:check
  • bun check

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 16, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
better-convex Ready Ready Preview, Comment Apr 17, 2026 9:35am

Request Review

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 16, 2026

⚠️ No Changeset found

Latest commit: 10472f7

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes changesets to release 2 packages
Name Type
kitcn Minor
@kitcn/resend Minor

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 165e8fb35e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/kitcn/src/auth/registerRoutes.ts
@zbeyens zbeyens changed the title Sync Convex Better Auth runtime fixes Sync Convex Better Auth fixes and make auth route registration lazy by default Apr 16, 2026
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 909b10b426

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread .agents/skills/sync-convex-auth/SKILL.md Outdated
@zbeyens zbeyens changed the title Sync Convex Better Auth fixes and make auth route registration lazy by default Sync Convex Better Auth fixes and tighten custom auth route basePath wiring Apr 16, 2026
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 544f0a9e72

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread .agents/rules/sync-convex-auth.mdc Outdated
Comment thread .agents/rules/sync-convex-auth.mdc
@zbeyens zbeyens changed the title Sync Convex Better Auth fixes and tighten custom auth route basePath wiring Sync Convex Better Auth fixes and support Better Auth 1.6.5 Apr 16, 2026
@zbeyens
Copy link
Copy Markdown
Member Author

zbeyens commented Apr 16, 2026

"No Changeset found"

Addressed: the PR now includes an updated unreleased changeset. The bot comment is stale and still reflects an earlier draft.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 85d34f9f3e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/kitcn/src/auth/adapter-utils.ts
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3c7cc2e78a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/kitcn/src/auth/adapter-utils.ts Outdated
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 20ae262dd5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread .agents/skills/sync-convex-auth/SKILL.md Outdated
Comment thread packages/kitcn/src/react/auth-mutations.ts Outdated
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f83601b54e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/kitcn/src/auth-start/index.ts
Comment thread packages/kitcn/src/auth/internal/token.ts
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9e020b50d1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/kitcn/src/auth/internal/convex-plugin.ts Outdated
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ec9f84518e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +63 to +64
if (originalHost) {
headers.set('x-forwarded-host', originalHost);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Ignore client-supplied forwarded-host override headers

restoreOriginalForwardedHeaders trusts x-better-auth-forwarded-host/proto from the incoming request and copies them into x-forwarded-host/proto without validating the request source. Because these headers are client-controllable on direct requests to the Convex auth endpoint, an attacker can spoof the effective origin seen by Better Auth (for redirects/callback URL construction and related host-based logic), which is a security regression introduced by this proxy-restore path.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

an attacker can spoof the effective origin seen by Better Auth ... which is a security regression introduced by this proxy-restore path

Valid concern. I fixed the correctness regressions in this pass, but I’m leaving this thread open because the safe fix needs a real trust boundary for those preserved headers, not a heuristic that only looks secure.

Comment thread packages/kitcn/src/auth/internal/token.ts Outdated
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 17f483784a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/kitcn/src/auth/internal/convex-client.ts
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b5ddefe8c3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread .agents/skills/sync-convex-auth/SKILL.md
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 10472f72ca

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +5 to +7
basePath && basePath !== '/'
? basePath.replace(TRAILING_SLASH_RE, '')
: '/api/auth';
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve root basePath when resolving token endpoint

resolveConvexTokenPath currently treats basePath: "/" as the default case and rewrites it to "/api/auth", so token fetches go to /api/auth/convex/token instead of /convex/token. In deployments that intentionally mount Better Auth at root, server-side token refresh will hit the wrong route (404/unauthorized), breaking authenticated Next.js/TanStack Start calls despite an explicit basePath configuration.

Useful? React with 👍 / 👎.

@zbeyens zbeyens merged commit 0b4cf81 into main Apr 17, 2026
3 checks passed
@zbeyens zbeyens deleted the codex/sync-convex-auth-0-11-4 branch April 17, 2026 09:54
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.

1 participant