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

supabase/ssr export error in browser #725

Closed
2 tasks done
Aietes opened this issue Jan 24, 2024 · 6 comments
Closed
2 tasks done

supabase/ssr export error in browser #725

Aietes opened this issue Jan 24, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@Aietes
Copy link

Aietes commented Jan 24, 2024

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 using supabase/ssr in Nuxt, provided via a Nuxt module, I get the following error in the browser:

Uncaught SyntaxError: The requested module '/_nuxt/node_modules/.pnpm/cookie@0.5.0/node_modules/cookie/index.js?v=d88ad7de' does not provide an export named 'parse'

It comes from packages/ssr/src/utils/helpers.ts, where cookie helper functions are imported:

export { parse, serialize } from 'cookie';

Is there anything I can do about it? The issue seems to be that I'm using ssr in a ESM module, and the helper functions are CommonJS. There seem to be a pull request in the cookie library, but it's not merged yet, and ssr would still need to update the dependency.

Expected behavior

No module export error in the browser.

System information

  • OS: macOS
  • Browser: chrome, safari
  • Version of supabase-js: 2.39.3 (ssr 0.0.10)
  • Version of Node.js: v21.6.1

Additional context

Add any other context about the problem here.

@Aietes Aietes added the bug Something isn't working label Jan 24, 2024
@Aietes
Copy link
Author

Aietes commented Jan 30, 2024

I worked around the issue by pre-bundling the package using optimizeDeps in Vite. This fixes the error, I believe Vite fixes the imports/exports during the build.

@phillipmohr
Copy link

Is this fixed? I'm using Nuxt 3 and I upgraded to "@nuxtjs/supabase": "^1.4.0" and "@supabase/supabase-js": "^2.45.3" but still getting this error.

@peterhel
Copy link

peterhel commented Sep 6, 2024

@phillipmohr I've been tackling the same issue with nuxt3. I just got it working by deleting node_modules and package-lock.json, then clearing the versions from package.json:

    "dependencies": {
        "@nuxtjs/supabase": "",
        "@supabase/ssr": "",
        "@supabase/supabase-js": "",
        ....
    }

npm install and npm run dev... BOOM! works (on my machine). Hope it helps!

@phillipmohr
Copy link

@phillipmohr I've been tackling the same issue with nuxt3. I just got it working by deleting node_modules and package-lock.json, then clearing the versions from package.json:

    "dependencies": {
        "@nuxtjs/supabase": "",
        "@supabase/ssr": "",
        "@supabase/supabase-js": "",
        ....
    }

npm install and npm run dev... BOOM! works (on my machine). Hope it helps!

Unfortunately no luck for me :( i'm using pnpm though. When I try to run pnpm i after setting the versions to "" I'm getting an error.

Can you let me know what versions of nuxt, @nuxtjs/supabase, @supabase/ssr and @supabase/supabase-js you are using?

@phillipmohr
Copy link

I "fixed it" by downgrading. I've done some digging and in the docs here: https://supabase.nuxtjs.org/changelog#v1.3.1 I found this entry: We're now using the @supabase/ssr library under the hood 🎉 (#357) for version 1.3.1.

So I downgraded to v1.2.2 and the error is gone.

I'm not sure if the issue should be addressed here or in the Supabase nuxt module?

@Aietes
Copy link
Author

Aietes commented Sep 9, 2024

@phillipmohr This should probably be addressed in the Nuxt module.

We are using our own version of the supabase nuxt module at the moment, in which we have adapted the latest supabase/ssr changes, which handles ssr and auth quite differently than before: https://github.com/floatingpixels/supabase-nuxt.

I was helping with adapting the supabase Nuxt module for the PKCE flow a while back, but didn't have time to create pull requests for the more recent supbase/ssr switch. In our version of the module we moved the PKCE flow to the server again, and leave most of the cookie handling to the supbase/ssr library, which avoids errors like the one you are likely facing.

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

3 participants