auth-js icon indicating copy to clipboard operation
auth-js copied to clipboard

`window is not defined` error in `_initialize()`

Open azzazzel opened this issue 1 year ago • 7 comments

Bug report

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

Describe the bug

This change https://github.com/supabase/auth-js/commit/9751b8029b4235a63dcb525e7ce7cc942c85daf5#diff-3522461172efd6058d6b8da62fc2d30d8b524d2b64894ea2c67218c52f7fdff5R310 seems to introduce a ReferenceError: window is not defined error when initializing auth server-side via createServerClient from @supabase/ssr

To Reproduce

The error occurred in a Nuxt.js app however it should be reproducible by

import { createServerClient } from "@supabase/ssr";

const client = createServerClient(url, key, options);
await client.auth.getSession();

in any SSR-based app.

System information

  • OS: macOS
  • Version of Node.js: v23.3.0
  • Version of supabase-js: 2.47.10
  • Version of @supabase/auth-js: 2.67.3,
  • Version of @supabase/ssr: 0.5.2,

azzazzel avatar Jan 14 '25 15:01 azzazzel