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

{ "code": 400, "error_code": "validation_failed", "msg": "Unsupported logout scope \"window\"" } #1227

Open
YA9 opened this issue Jun 20, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@YA9
Copy link

YA9 commented Jun 20, 2024

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

When I try supabase.auth.signOut(), on version 2.43.3 on JS, I get this error:
{
"code": 400,
"error_code": "validation_failed",
"msg": "Unsupported logout scope "window""
}

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. In a deployed production environment only, when I run supabase.auth.signOut(), I get the error above. In development, before compiling, it works fine.
  2. See error

Expected behavior

A clear and concise description of what you expected to happen.

Screenshots

image

System information

  • OS: [macOS, Windows]
  • Browser (if applies) [chrome]
  • Version of supabase-js: [2.43.3]
@YA9 YA9 added the bug Something isn't working label Jun 20, 2024
@YA9
Copy link
Author

YA9 commented Jun 20, 2024

I found a fix for this. It doesn't make sense why this works, but

 supabase.auth
      .signOut({ scope: 'local' })

putting scope local, instead of leaving it empty worked. Seems like there's an error with scope global

@YA9
Copy link
Author

YA9 commented Jun 20, 2024

There's still another issue relating to this. When upgrading to the latest version: 2.43.5, everything breaks and I get this error:

Screenshot 2024-06-19 192313

On version 2.43.2, I don't get this error, and things work fine in production.

@bcurioous
Copy link

bcurioous commented Jul 17, 2024

Having the same issue, I faced both the issue mentioned here.

@bcurioous
Copy link

I found a solution to the issue. Check your build configuration steps. In my case, I was using Vite.js, which had a global: 'window' transformation configuration. Commenting out that line prevents the global keyword from being transformed into window.

The Supabase-JS client code uses a global object. However, during the Vite.js build, this was being converted to window. In the browser, the window object refers to the document object, which does not contain the global values, leading to the breakage.

Here's the updated configuration:

export default defineConfig({
  define: {
//    global: 'window',
  },
  // other configurations
});

This change resolved the issue for me.
If you need further assistance, feel free to ask!

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

2 participants