Hebilicious / authjs-nuxt

AuthJS edge-compatible authentication Nuxt module.
https://authjs-nuxt.pages.dev/
MIT License
253 stars 28 forks source link

Cookie import error #2

Open v-moravec opened 1 year ago

v-moravec commented 1 year ago

Hi,

I'm getting this error with this module:

Uncaught SyntaxError: The requested module '/_nuxt/node_modules/cookie/index.js?v=41251351' does not provide an export named 'parse' (at web.js?v=41251351:1:10)

When I tried to implement it myself, I don't get this error (it works locally), but I can't build for CF Pages, because of crypto dependency, which I can't get rid of.

Hebilicious commented 1 year ago

I am not sure why this bug is happening, but as a workaround, you can try to install cookie, and to add this to your package.json :

export default defineNuxtConfig({
  alias: {
    cookie: path.resolve(__dirname, "node_modules/cookie")
  }
})
v-moravec commented 1 year ago

Yes that solved it, thanks. I suspect, it might have something to do with the @auth/core version, since it doesn't happen to me with '0.8.1'. I also solved the problem with my setup - I had to add this:

import {createResolver} from '@nuxt/kit'

const { resolve } = createResolver(import.meta.url)

export default defineNuxtConfig({
  alias: {
    "jose": resolve(__dirname, "./node_modules/jose/dist/browser/index.js"),
    "@panva/hkdf": resolve(__dirname, "./node_modules/@panva/hkdf/dist/web/index.js")
  }
)}

And now it works on edge runtime.

Hebilicious commented 1 year ago

@v-moravec This should be fixed with https://github.com/Hebilicious/authjs-nuxt/commit/6dde4c3d4acac044f44ac7e6d1f66317aff47db5 Please let me know if you're still having issues with the latest versions.

Hebilicious commented 1 year ago

I think it has to do with something wrong within @auth/core and therefore I added the workaround to the documentation. I'll leave this open just in case there's a better solution down the line.

dissy123 commented 1 year ago

Hi,

I installed the cookie package also via pnpm i and then added an alias, and it is finding the package.

But now i get:

[auth][error][InvalidCheck]: Read more at https://errors.authjs.dev#invalidcheck [auth][cause]: InvalidCheck: PKCE code_verifier cookie was missing.

is this related to that bug? on the login page is only one cookie set that one with the redirect url.

Would be great if someone has an idea on this :)

Hebilicious commented 1 year ago

Hi,

I installed the cookie package also via pnpm i and then added an alias, and it is finding the package.

But now i get:

[auth][error][InvalidCheck]: Read more at https://errors.authjs.dev#invalidcheck [auth][cause]: InvalidCheck: PKCE code_verifier cookie was missing.

is this related to that bug? on the login page is only one cookie set that one with the redirect url.

Would be great if someone has an idea on this :)

Can you please open a new issue with a reproduction ?

Q16solver commented 1 year ago

@Hebilicious Should this be raised as an upstream issue in the authjs repo?

Hebilicious commented 1 year ago

@Hebilicious Should this be raised as an upstream issue in the authjs repo?

I think it could yes.

ben05allen commented 9 months ago

I have what seems to be a related issue: Uncaught SyntaxError: ambiguous indirect export: parse [web.js:1:10](http://localhost:3000/_nuxt/node_modules/@auth/core/lib/web.js?v=4475a7ed)

niko-chaffinchicas commented 7 months ago

I am not sure why this bug is happening, but as a workaround, you can try to install cookie, and to add this to your package.json :

export default defineNuxtConfig({
  alias: {
    cookie: path.resolve(__dirname, "node_modules/cookie")
  }
})

@Hebilicious Thank you for this, this had been causing issues for me as well.

It didn't look like anyone has raised an issue upstream with @auth/core yet, and the latest version 0.30.0 still has this issue. Shall I go ahead and open that issue?