RequestAsyncStorage error with NextJS 14 and @supabase/ssr

This is my server client from
@supabase/ssr
:
import { Database } from '@/types';
import { createServerClient, type CookieOptions } from '@supabase/ssr';
import { cookies } from 'next/headers';

const cookieStore = cookies();

export const serverSupabase = createServerClient<Database>(
    process.env.NEXT_PUBLIC_SUPABASE_URL!,
    process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
    {
        cookies: {
            get(name: string) {
                return cookieStore.get(name)?.value;
            },
            set(name: string, value: string, options: CookieOptions) {
                cookieStore.set({ name, value, ...options });
            },
            remove(name: string, options: CookieOptions) {
                cookieStore.delete({ name, ...options });
            },
        },
    }
);


I am importing it into route handlers, middleware and RSC.
Using NextJS 14.0.1, and I get this error when trying to build:
Error: Invariant: cookies() expects to have requestAsyncStorage, none available.
Error: Failed to collect page data for /auth/sign-out, same goes for collecting page data for others that import the supabase server client.
Was this page helpful?