Closed christopherdro closed 1 year ago
My current workaround is to use postgrest-js and remove cross-fetch
from its dependencies.
https://github.com/christopherdro/postgrest-js/commit/ee678bc8342211f0948c9ff828d285503eb54bf5
Actually, it's not just the realtime part that is affected. gotrue-js
and postgres-js
are both affected too.
Anything that import
directly cross-fetch
without using a dynamic import is gonna cause the problem I suppose.
I can verify that we are affected by this issue as well in one of your projects.
I also have this problem in the recently released Next.js 12.2 where middleware is now stable.
We are also affected by this in middleware. Should we expect a quick fix or try to find a workaround?
I believe this PR should fix the issue: https://github.com/vercel/next.js/pull/38234
In the meantime you can try using the Node.js-based API Routes instead of the Edge API Routes - you can do this by removing the runtime: 'experimental-edge'
config.
Additionally we're also working on changing the way we package our client libs which should also fix this issue, though this may take some time.
The fix is still being discussed. For Edge API route, I recommend you to switch back to regular routes, as @soedirgo suggested. Fixing them may require a bit more time than fixing the middleware.
This should be resolved as of next@12.2.1
:)
Bug report
I recently tried updating to NextJS v12.1.6 and noticed that @supabase/supabase-js can no longer be used in Edge Functions. This is because native NodeJS APIs are not supported and it appears there are some dependencies of realtime-js that use these. Here is a look at the stack trace.
To Reproduce
Upgrade to NextJS 12.1.6 and try to use @supabase/supabase-js lib within a middleware function.
Additional context