The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
added back authOptions – turns out we still need it cause we're using Prisma adapter
Steven Teyb54252127902
diff --git a/lib/auth.ts b/lib/auth.tsindex 9b67eb061c..3643302525 100644--- a/lib/auth.ts+++ b/lib/auth.ts@@ -3,7 +3,7 @@ import { unstable_getServerSession } from "next-auth/next";import { FREE_PLAN_PROJECT_LIMIT } from "@/lib/constants";import prisma from "@/lib/prisma";import { ProjectProps, UserProps } from "@/lib/types";-+import { authOptions } from "@/pages/api/auth/[...nextauth]";export interface Session {user: {email?: string | null;@@ -11,6 +11,13 @@ export interface Session {name?: string | null;};}++export async function getServerSession(+ req: NextApiRequest,+ res: NextApiResponse,+) {+ return (await unstable_getServerSession(req, res, authOptions)) as Session;+}interface WithProjectNextApiHandler {(req: NextApiRequest,@@ -36,7 +43,7 @@ const withProjectAuth =} = {},) =>async (req: NextApiRequest, res: NextApiResponse) => {- const session = (await unstable_getServerSession()) as Session;+ const session = await getServerSession(req, res);if (!session?.user.id) return res.status(401).end("Unauthorized");const { slug } = req.query;@@ -142,8 +149,7 @@ const withUserAuth =} = {},) =>async (req: NextApiRequest, res: NextApiResponse) => {- const session = (await unstable_getServerSession()) as Session;- console.log("session", session);+ const session = await getServerSession(req, res);if (!session?.user.id) return res.status(401).end("Unauthorized");if (req.method === "GET") return handler(req, res, session);diff --git a/package.json b/package.jsonindex e2fac50467..1b4ae5c262 100644--- a/package.json+++ b/package.json@@ -12,7 +12,7 @@"start": "next start"},"dependencies": {- "@next-auth/prisma-adapter": "^1.0.4",+ "@next-auth/prisma-adapter": "^1.0.5","@next/font": "^13.0.2","@prisma/client": "^4.3.1","@radix-ui/react-accordion": "^1.0.1",diff --git a/yarn.lock b/yarn.lockindex 6e6066a352..734d594fcd 100644--- a/yarn.lock+++ b/yarn.lock@@ -429,10 +429,10 @@hey-listen "^1.0.8"tslib "^2.3.1"-"@next-auth/prisma-adapter@^1.0.4":- version "1.0.4"- resolved "https://registry.npmjs.org/@next-auth/prisma-adapter/-/prisma-adapter-1.0.4.tgz"- integrity sha512-jIOM6CzCbl2/Mzbx9kb2IjtHoJOeRN9wtQgLk4EUm5bhneSVGv1rtz5TDskvp2UfCa+EK9nDmug+lje41z80Gg==+"@next-auth/prisma-adapter@^1.0.5":+ version "1.0.5"+ resolved "https://registry.yarnpkg.com/@next-auth/prisma-adapter/-/prisma-adapter-1.0.5.tgz#41a2fc7b44907054b81d456b426164e58becf4ed"+ integrity sha512-VqMS11IxPXrPGXw6Oul6jcyS/n8GLOWzRMrPr3EMdtD6eOalM6zz05j08PcNiis8QzkfuYnCv49OvufTuaEwYQ=="@next/[email protected]":version "13.0.2"