From e9ac7aefdb427e0c74a9c22c055aed930fb52c4b Mon Sep 17 00:00:00 2001 From: pilcrowOnPaper Date: Wed, 16 Oct 2024 09:33:50 +0900 Subject: [PATCH] fix nextjs docs --- pages/sessions/cookies/nextjs.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pages/sessions/cookies/nextjs.md b/pages/sessions/cookies/nextjs.md index 068b743..f754e58 100644 --- a/pages/sessions/cookies/nextjs.md +++ b/pages/sessions/cookies/nextjs.md @@ -76,7 +76,7 @@ export function deleteSessionTokenCookie(): void { cookies().set("session", "", { httpOnly: true, sameSite: "lax", - secure: import.meta.env.PROD, + secure: process.env.NODE_ENV === "production", maxAge: 0, path: "/" }); @@ -124,10 +124,10 @@ Sessions can be validated by getting the cookie and using the `validateSessionTo ```ts import { validateSessionToken } from "$lib/server/session"; -import type { APIContext } from "astro"; +import type { NextRequest } from "next/server"; -export async function GET(context: APIContext): Promise { - const token = cookies().get("session")?.value ?? null; +export async function GET(request: NextRequest): Promise { + const token = request.cookies.get("session")?.value ?? null; if (token === null) { return new Response(null, { status: 401