#a cookie property was accessed directly with `cookies().getAll()`. `cookies()` should be awaited

3 messages · Page 1 of 1 (latest)

vestal imp
#

Hey, I just recently upgraded to next js 15. My project is a standard Nextjs + supabase stack. I know I am getting the error in the utils/supabase/server.ts file but I am not sure how to fix it.
Here is my code:

import { createServerClient } from '@supabase/ssr'
import { cookies, type UnsafeUnwrappedCookies } from 'next/headers';

export function createClient() {
const cookieStore = (cookies() as unknown as UnsafeUnwrappedCookies)

// Create a server's supabase client with newly configured cookie,
// which could be used to maintain user's session
return createServerClient(
process.env.NEXT_PUBLIC_SUPABASE_URL!,
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
{
cookies: {
getAll() {
return cookieStore.getAll()
},
setAll(cookiesToSet) {
try {
cookiesToSet.forEach(({ name, value, options }) =>
cookieStore.set(name, value, options)
)
} catch {
// The setAll method was called from a Server Component.
// This can be ignored if you have middleware refreshing
// user sessions.
}
},
},
}
)
}

rustic barnBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

vestal imp
#

Just to note if i turn the createClient function into async and then await cookies(), it gives me this error:
Error: supabase.from is not a function.