Skip to content

Error when creating a Supabase server client with the Quasar Framework #79

Open
@cvillagrasa

Description

@cvillagrasa

Bug report

  • I confirm this is a bug with Supabase, not with my own application.
  • I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

I'm getting an error on line

allCookies?.find(({ name }) => name === chunkName) || null;
when creating a Supabase server client on the Quasar Framework:

.../node_modules/@supabase/ssr/dist/main/cookies.js:238
    cookie = allCookies?.find(({ name }) => name === chunkName) || null;
                                               ^

TypeError: allCookies?.find is not a function

IMPORTANT: The error is solved if adding an additional optional chaining operator to the supabase source, as in allCookies?.find?.(. Not sure if there's any underlying issue, though.

To Reproduce

This is how I'm creating the client:

import { Cookies } from 'quasar';
import { QSsrContext } from '@quasar/app-vite';
import { createServerClient, type CookieOptions } from '@supabase/ssr';

function initSupabaseServer(ssrContext: QSsrContext) {
  const cookies = Cookies.parseSSR(ssrContext)
  return createServerClient(
    process.env.VITE_SUPABASE_URL!,
    process.env.VITE_SUPABASE_ANON_KEY!,
    {
      cookies: {
        getAll: () => cookies?.getAll(),
        setAll: (cookiesToSet: {
          name: string
          value: string
          options: CookieOptions
        }[]) => {
          cookiesToSet.forEach(({ name, value, options }) =>
            cookies.set(name ,value, options)
          )
        }
      }
    }
  )
}

The Cookies.parseSSR bit is in accordance with Quasar SSR instructions.

Screenshots

image

System information

  • OS: Ubuntu 24.04
  • Version of @supabase/ssr: 0.5.1
  • Version of Node.js: 18.18.2
  • Version of Quasar: 2.17.1
  • Version of Vue: 3.5.12

Additional context

This error happens both during development with Vite, and in production when running Node.js

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions