feat: setup better-auth
This commit is contained in:
@@ -3,6 +3,8 @@ import { useForm } from "react-hook-form";
|
||||
import { FaGoogle } from "react-icons/fa";
|
||||
import { z } from "zod";
|
||||
|
||||
import { authClient } from "@kan/auth";
|
||||
|
||||
import Button from "~/components/Button";
|
||||
import Input from "~/components/Input";
|
||||
import { api } from "~/utils/api";
|
||||
@@ -55,7 +57,12 @@ export function Auth({ setIsMagicLinkSent }: AuthProps) {
|
||||
<div className="space-y-6">
|
||||
<div>
|
||||
<Button
|
||||
onClick={() => loginWithOAuth.mutate({ provider: "google" })}
|
||||
onClick={() =>
|
||||
authClient.signIn.social({
|
||||
provider: "google",
|
||||
callbackURL: "/boards",
|
||||
})
|
||||
}
|
||||
iconLeft={<FaGoogle />}
|
||||
fullWidth
|
||||
size="lg"
|
||||
|
||||
@@ -16,6 +16,8 @@ export const env = createEnv({
|
||||
server: {
|
||||
POSTGRES_URL: z.string().url(),
|
||||
STRIPE_SECRET_KEY: z.string().optional(),
|
||||
GOOGLE_CLIENT_ID: z.string(),
|
||||
GOOGLE_CLIENT_SECRET: z.string(),
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
6
apps/web/src/pages/api/auth/[...all].ts
Normal file
6
apps/web/src/pages/api/auth/[...all].ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import { toNodeHandler } from "better-auth/node";
|
||||
|
||||
import { auth } from "@kan/auth";
|
||||
|
||||
export const config = { api: { bodyParser: false } };
|
||||
export default toNodeHandler(auth.handler);
|
||||
Reference in New Issue
Block a user