CookieOptions type error when using example OAuth PKCE code from Supabase docs

Hello! I'm getting a typescript error when using the following code from Supabase's documentation on server side OAuth: https://supabase.com/docs/guides/auth/server-side/oauth-with-pkce-flow-for-ssr#create-api-endpoint-for-handling-the-code-exchange

import { cookies } from 'next/headers'
import { NextResponse } from 'next/server'
import { type CookieOptions, createServerClient } from '@supabase/ssr'

export async function GET(request: Request) {
  const { searchParams, origin } = new URL(request.url)
  const code = searchParams.get('code')
  // if "next" is in param, use it as the redirect URL
  const next = searchParams.get('next') ?? '/'

  if (code) {
    const cookieStore = cookies()
    const supabase = createServerClient(
      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 })
          },
// TypeError: Unsafe argument of type `any` assigned to a parameter of type `[key: string, value: string, cookie?: Partial<ResponseCookie> | undefined] | [options: ResponseCookie]`.
          remove(name: string, options: CookieOptions) {
            cookieStore.delete({ name, ...options })
// TypeError: Unsafe argument of type `any` assigned to a parameter of type `[key: string] | [options: Omit<ResponseCookie, "value" | "expires">]`.
          },
        },
      }
    )
...
}


Does anyone know how I might resolve these typing issues? It looks like the error is coming from the way options is passed in to the cookieStore methods.

Thanks!
Learn how to configure OAuth authentication in your server-side rendering (SSR) application to work with the PKCE flow.
Was this page helpful?