feat: edge ready
This commit is contained in:
@@ -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