Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
2 tasks done
cvillagrasa opened this issue Nov 10, 2024 · 0 comments
Open
2 tasks done
Labels
bug Something isn't working

Comments

@cvillagrasa
Copy link

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

@cvillagrasa cvillagrasa added the bug Something isn't working label Nov 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant