supabase / auth-helpers

A collection of framework specific Auth utilities for working with Supabase.

Home Page:https://supabase.github.io/auth-helpers/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Vite 5 breaks @supabase/ssr createBrowserClient

wiesson opened this issue · comments

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

When upgrading to Vite 5 in a Sveltekit project (haven't tried Astro, it was released yesterday with Vite5 as well), the createBrowserClient can't find fetch

Error:

start.js:28 Uncaught (in promise) ReferenceError: global is not defined
    at node_modules/.pnpm/@supabase+node-fetch@2.6.15/node_modules/@supabase/node-fetch/lib/index.js (index.js:660:16)
    at __require (chunk-LNEMQRCO.js?v=60ef7ba7:9:50)
    at PostgrestBuilder.ts:2:23
node_modules/.pnpm/@supabase+node-fetch@2.6.15/node_modules/@supabase/node-fetch/lib/index.js @ index.js:660
__require @ chunk-LNEMQRCO.js?v=60ef7ba7:9
(anonymous) @ PostgrestBuilder.ts:2
await in (anonymous) (async)
(anonymous) @ auth:27
Promise.then (async)
(anonymous) @ auth:26
Show 2 more frames
Show less

To Reproduce

  1. Add the createBrowserClient code as described here: https://supabase.com/docs/guides/auth/server-side/creating-a-client?framework=sveltekit&environment=layout
  2. Go to any page that likes to use the browser client

or clone https://github.com/wiesson/sveltekit-vite5-supabase-browserclient, add a .env

PUBLIC_SUPABASE_URL
PUBLIC_SUPABASE_ANON_KEY

Expected behavior

Should work as with Vite4. Maybe it's time to remove node-fetch from the supabase client and reply on the node internal one?

System information

  • OS: [macOS]
  • Browser (if applies) [latest chrome]
  • Version of supabase-js: [@supabase/ssr 0.10]
  • Version of Node.js: [v18.18.2]

Additional context

Add any other context about the problem here.

I can't reproduce it anymore, looks like it was fixed somehow