© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•3y ago•
4 replies
IsoPhoenix

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">]`.
          },
        },
      }
    )
...
}
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
options
is passed in to the
cookieStore
cookieStore
methods.

Thanks!
OAuth with PKCE flow for SSR | Supabase Docs
Learn how to configure OAuth authentication in your server-side rendering (SSR) application to work with the PKCE flow.
OAuth with PKCE flow for SSR | Supabase Docs
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

type error when using definition from openapi
SupabaseSSupabase / help-and-questions
4y ago
Local Supabase OAuth Error
SupabaseSSupabase / help-and-questions
3y ago
Azure OAuth PKCE Error with Single-Tenant Configuration
SupabaseSSupabase / help-and-questions
2mo ago
error.code is undefined when using supabase.auth.updateUser
SupabaseSSupabase / help-and-questions
14mo ago