feat: edge ready
This commit is contained in:
@@ -26,7 +26,7 @@
|
||||
"drizzle-orm": "^0.28.5",
|
||||
"formik": "^2.4.5",
|
||||
"next": "^13.5.4",
|
||||
"next-auth": "^4.24.4",
|
||||
"next-auth": "0.0.0-manual.cfb42ae7",
|
||||
"react": "18.2.0",
|
||||
"react-beautiful-dnd": "^13.1.1",
|
||||
"react-contenteditable": "^3.3.7",
|
||||
|
||||
3976
pnpm-lock.yaml
generated
Normal file
3976
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,7 @@
|
||||
import Image from "next/image";
|
||||
import { redirect } from "next/navigation";
|
||||
|
||||
import { getServerAuthSession } from "~/server/auth";
|
||||
import { auth } from "~/server/auth";
|
||||
|
||||
import boardsIcon from "~/app/assets/boards.json";
|
||||
|
||||
@@ -12,7 +12,7 @@ const navigation = [
|
||||
];
|
||||
|
||||
export default async function Layout(props: { children: React.ReactNode }) {
|
||||
const session = await getServerAuthSession();
|
||||
const session = await auth();
|
||||
|
||||
if (!session?.user) redirect("api/auth/signin");
|
||||
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
import NextAuth from "next-auth";
|
||||
export { GET, POST } from "~/server/auth";
|
||||
|
||||
import { authOptions } from "~/server/auth";
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||
const handler = NextAuth(authOptions);
|
||||
export { handler as GET, handler as POST };
|
||||
|
||||
// export const runtime = "edge";
|
||||
// export const preferredRegion = 'lhr1';
|
||||
// export const dynamic = 'force-dynamic'
|
||||
export const runtime = "edge";
|
||||
export const preferredRegion = 'lhr1';
|
||||
export const dynamic = 'force-dynamic'
|
||||
|
||||
@@ -23,6 +23,6 @@ const handler = (req: NextRequest) =>
|
||||
|
||||
export { handler as GET, handler as POST };
|
||||
|
||||
// export const runtime = "edge";
|
||||
// export const preferredRegion = 'lhr1';
|
||||
// export const dynamic = 'force-dynamic'
|
||||
export const runtime = "edge";
|
||||
export const preferredRegion = 'lhr1';
|
||||
export const dynamic = 'force-dynamic'
|
||||
|
||||
@@ -2,17 +2,17 @@ import { Login } from "~/app/_components/auth";
|
||||
|
||||
export default function LoginPage() {
|
||||
return (
|
||||
<main className="bg-dark-50 flex h-screen flex-col items-center justify-center">
|
||||
<h1 className="text-dark-1000 mb-6 text-lg font-normal tracking-tight">
|
||||
<main className="flex h-screen flex-col items-center justify-center bg-dark-50">
|
||||
<h1 className="mb-6 text-lg font-normal tracking-tight text-dark-1000">
|
||||
貫 kan
|
||||
</h1>
|
||||
<p className="text-dark-1000 mb-10 text-3xl">Get started</p>
|
||||
<div className="bg-dark-400 border-dark-600 w-full rounded-md border px-10 py-10 sm:max-w-md">
|
||||
<p className="mb-10 text-3xl text-dark-1000">Get started</p>
|
||||
<div className="w-full rounded-md border border-dark-600 bg-dark-300 px-10 py-10 sm:max-w-md">
|
||||
<div className=" sm:mx-auto sm:w-full sm:max-w-sm">
|
||||
<Login />
|
||||
</div>
|
||||
</div>
|
||||
<p className="text-dark-1000 mt-10 text-center text-sm">
|
||||
<p className="mt-10 text-center text-sm text-dark-1000">
|
||||
{"Already have an account?"}
|
||||
</p>
|
||||
</main>
|
||||
|
||||
@@ -12,7 +12,7 @@ import { type NextRequest } from "next/server";
|
||||
import superjson from "superjson";
|
||||
import { ZodError } from "zod";
|
||||
|
||||
import { getServerAuthSession } from "~/server/auth";
|
||||
import { auth } from "~/server/auth";
|
||||
import { db } from "~/server/db";
|
||||
|
||||
/**
|
||||
@@ -38,7 +38,7 @@ interface CreateContextOptions {
|
||||
* @see https://create.t3.gg/en/usage/trpc#-serverapitrpcts
|
||||
*/
|
||||
export const createInnerTRPCContext = async (opts: CreateContextOptions) => {
|
||||
const session = await getServerAuthSession();
|
||||
const session = await auth();
|
||||
|
||||
return {
|
||||
session,
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
import { DrizzleAdapter } from "@auth/drizzle-adapter";
|
||||
import {
|
||||
getServerSession,
|
||||
type DefaultSession,
|
||||
type NextAuthOptions,
|
||||
} from "next-auth";
|
||||
import NextAuth, { type DefaultSession } from "next-auth";
|
||||
|
||||
import { db } from "~/server/db";
|
||||
import { mySqlTable } from "~/server/db/schema";
|
||||
@@ -29,18 +25,18 @@ declare module "next-auth" {
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
* Options for NextAuth.js used to configure adapters, providers, callbacks, etc.
|
||||
*
|
||||
* @see https://next-auth.js.org/configuration/options
|
||||
*/
|
||||
export const authOptions: NextAuthOptions = {
|
||||
export const {
|
||||
handlers: { GET, POST },
|
||||
auth,
|
||||
} = NextAuth({
|
||||
callbacks: {
|
||||
session: ({ session, user }) => ({
|
||||
...session,
|
||||
user: {
|
||||
...session.user,
|
||||
id: user.id,
|
||||
name: session.user.name,
|
||||
email: session.user.email,
|
||||
image: session.user.image,
|
||||
},
|
||||
}),
|
||||
},
|
||||
@@ -82,11 +78,4 @@ export const authOptions: NextAuthOptions = {
|
||||
},
|
||||
}
|
||||
],
|
||||
};
|
||||
|
||||
/**
|
||||
* Wrapper for `getServerSession` so that you don't need to import the `authOptions` in every file.
|
||||
*
|
||||
* @see https://next-auth.js.org/configuration/nextjs
|
||||
*/
|
||||
export const getServerAuthSession = () => getServerSession(authOptions);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user