From 64201094b1a9c9fe18f84ef6e4a8b7d9435fd3cf Mon Sep 17 00:00:00 2001 From: Ahrary <19792517+Ahrary@users.noreply.github.com> Date: Sun, 16 Mar 2025 02:46:47 -0400 Subject: [PATCH 1/4] Refactor: Add `await` to `cookies()` in step-5 to comply with Next.js 15 async API changes --- .../docs/tutorials/nextjs-ssr-auth/step-5/+page.markdoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/routes/docs/tutorials/nextjs-ssr-auth/step-5/+page.markdoc b/src/routes/docs/tutorials/nextjs-ssr-auth/step-5/+page.markdoc index 086851e921..fe032b6485 100644 --- a/src/routes/docs/tutorials/nextjs-ssr-auth/step-5/+page.markdoc +++ b/src/routes/docs/tutorials/nextjs-ssr-auth/step-5/+page.markdoc @@ -72,7 +72,7 @@ async function signUpWithEmail(formData) { await account.create(ID.unique(), email, password, name); const session = await account.createEmailPasswordSession(email, password); - cookies().set("my-custom-session", session.secret, { + (await cookies()).set("my-custom-session", session.secret, { path: "/", httpOnly: true, sameSite: "strict", @@ -85,4 +85,4 @@ async function signUpWithEmail(formData) { // the SignUpPage component ... ``` -The `signUpWithEmail` function is an async function that takes the form data as an argument. It uses the `createAdminClient` function to create an admin Appwrite client and then calls the `createEmailPasswordSession` method on the `account` object. This method takes the email and password as arguments and returns a session object. We then set the session secret in a cookie and redirect the user to the account page. \ No newline at end of file +The `signUpWithEmail` function is an async function that takes the form data as an argument. It uses the `createAdminClient` function to create an admin Appwrite client and then calls the `createEmailPasswordSession` method on the `account` object. This method takes the email and password as arguments and returns a session object. We then set the session secret in a cookie and redirect the user to the account page. From 86fc420886dd0738f4c3a512dd7d568aa93af4a3 Mon Sep 17 00:00:00 2001 From: Ahrary <19792517+Ahrary@users.noreply.github.com> Date: Sun, 16 Mar 2025 02:50:17 -0400 Subject: [PATCH 2/4] Update +page.markdoc --- src/routes/docs/tutorials/nextjs-ssr-auth/step-3/+page.markdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routes/docs/tutorials/nextjs-ssr-auth/step-3/+page.markdoc b/src/routes/docs/tutorials/nextjs-ssr-auth/step-3/+page.markdoc index 09e8c0b3ce..b8145c7fea 100644 --- a/src/routes/docs/tutorials/nextjs-ssr-auth/step-3/+page.markdoc +++ b/src/routes/docs/tutorials/nextjs-ssr-auth/step-3/+page.markdoc @@ -20,7 +20,7 @@ export async function createSessionClient() { .setEndpoint(process.env.NEXT_PUBLIC_APPWRITE_ENDPOINT) .setProject(process.env.NEXT_PUBLIC_APPWRITE_PROJECT); - const session = await cookies().get("my-custom-session"); + const session = (await cookies()).get("my-custom-session"); if (!session || !session.value) { throw new Error("No session"); } From a77758e549961f305ad27a838e83774a7ef26f60 Mon Sep 17 00:00:00 2001 From: Ahrary <19792517+Ahrary@users.noreply.github.com> Date: Sun, 16 Mar 2025 02:54:07 -0400 Subject: [PATCH 3/4] Refactor: add 'await' to 'cookies()' call --- src/routes/docs/tutorials/nextjs-ssr-auth/step-6/+page.markdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routes/docs/tutorials/nextjs-ssr-auth/step-6/+page.markdoc b/src/routes/docs/tutorials/nextjs-ssr-auth/step-6/+page.markdoc index 367d9d8f21..6a03ffbbd7 100644 --- a/src/routes/docs/tutorials/nextjs-ssr-auth/step-6/+page.markdoc +++ b/src/routes/docs/tutorials/nextjs-ssr-auth/step-6/+page.markdoc @@ -22,7 +22,7 @@ async function signOut() { const { account } = await createSessionClient(); - cookies().delete("my-custom-session"); + (await cookies()).delete("my-custom-session"); await account.deleteSession("current"); redirect("/signup"); From 4ca48af53937bf16495d822ecd6b9cdf2cfb157c Mon Sep 17 00:00:00 2001 From: Ahrary <19792517+Ahrary@users.noreply.github.com> Date: Sun, 16 Mar 2025 03:06:53 -0400 Subject: [PATCH 4/4] Refactor: add 'await' to 'cookies()' and `headers()` call --- .../docs/tutorials/nextjs-ssr-auth/step-7/+page.markdoc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/routes/docs/tutorials/nextjs-ssr-auth/step-7/+page.markdoc b/src/routes/docs/tutorials/nextjs-ssr-auth/step-7/+page.markdoc index 6144261868..32fb49e332 100644 --- a/src/routes/docs/tutorials/nextjs-ssr-auth/step-7/+page.markdoc +++ b/src/routes/docs/tutorials/nextjs-ssr-auth/step-7/+page.markdoc @@ -27,7 +27,7 @@ import { OAuthProvider } from "node-appwrite"; export async function signUpWithGithub() { const { account } = await createAdminClient(); - const origin = headers().get("origin"); + const origin = (await headers()).get("origin"); const redirectUrl = await account.createOAuth2Token( OAuthProvider.Github, @@ -85,7 +85,7 @@ export async function GET(request) { const { account } = await createAdminClient(); const session = await account.createSession(userId, secret); - cookies().set("my-custom-session", session.secret, { + (await cookies()).set("my-custom-session", session.secret, { path: "/", httpOnly: true, sameSite: "strict", @@ -94,4 +94,4 @@ export async function GET(request) { return NextResponse.redirect(`${request.nextUrl.origin}/account`); } -``` \ No newline at end of file +```