20 lines
918 B
TypeScript
20 lines
918 B
TypeScript
// SPDX-License-Identifier: LicenseRef-ConusAI-Template-1.0
|
|
// /api/auth/*: the same-origin route from this app's pages to Better Auth on its Convex deployment
|
|
// (AUTH_PROVIDER=convex-better-auth). Only the endpoints a sign-in, sign-up, sign-out, password
|
|
// change, device revocation or account deletion needs are forwarded, and no bearer comes back
|
|
// (@conusai-kit/auth-convex-better-auth's proxy). A deployment that selected another provider has no
|
|
// such route.
|
|
import { loadAuthConfig } from "@conusai-kit/auth"
|
|
import { betterAuthRuntime } from "../../../../src/server/app"
|
|
|
|
export const dynamic = "force-dynamic"
|
|
export const runtime = "nodejs"
|
|
|
|
async function handle(request: Request): Promise<Response> {
|
|
if (loadAuthConfig().provider !== "convex-better-auth") return new Response(null, { status: 404 })
|
|
return betterAuthRuntime().proxy(request)
|
|
}
|
|
|
|
export const GET = handle
|
|
export const POST = handle
|