Skip to content

Commit 897a06b

Browse files
committed
fix(auth): accept Better Auth route contracts
1 parent b3a88ed commit 897a06b

3 files changed

Lines changed: 21 additions & 8 deletions

File tree

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
"kitcn": patch
3+
---
4+
5+
## Patches
6+
7+
- Fix raw auth reruns so `http.ts` import detection respects both quote styles,
8+
and `registerRoutes(http, getAuth, ...)` accepts Better Auth route contracts
9+
without a type cast.

packages/kitcn/src/auth/registerRoutes.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
11
/** biome-ignore-all lint/suspicious/noConsole: lib */
2+
import type { BaseURLConfig, BetterAuthOptions } from 'better-auth';
23
import { type HttpRouter, httpActionGeneric } from 'convex/server';
34
import { corsRouter } from '../internal/upstream/server/cors';
45
import { toAuthErrorResponse } from './error-response';
56

67
import type { GetAuth } from './types';
78

8-
type TrustedOriginsOption =
9-
| (string | null | undefined)[]
10-
| ((
11-
request?: Request
12-
) =>
13-
| (string | null | undefined)[]
14-
| Promise<(string | null | undefined)[]>);
9+
type TrustedOriginsOption = BetterAuthOptions['trustedOrigins'];
1510

1611
type AuthRouteContract = {
1712
$context: Promise<{
@@ -22,7 +17,7 @@ type AuthRouteContract = {
2217
handler: (request: Request) => Promise<Response>;
2318
options: {
2419
basePath?: string;
25-
baseURL?: unknown;
20+
baseURL?: BaseURLConfig;
2621
trustedOrigins?: TrustedOriginsOption;
2722
};
2823
};
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import type { Auth, BetterAuthOptions } from 'better-auth';
2+
import type { HttpRouter } from 'convex/server';
3+
4+
import { registerRoutes } from './registerRoutes';
5+
6+
declare const http: HttpRouter;
7+
declare const getAuth: (ctx: unknown) => Auth<BetterAuthOptions>;
8+
9+
registerRoutes(http, getAuth, { cors: false });

0 commit comments

Comments
 (0)