Google login not working ( [next-auth][error][CLIENT_FETCH_ERROR] )

First time I setup a project in V0, Google login worked instantly. But as I couldn’t get OAuth to work in the Preview, I disabled the login part while I built my app(NextJS, Supabase).

But now that I actually need the login, it’s impossible to get to work again. I’ve battled with it for multiple days - and nothing seems to fix it. I wondered whether it was an error related to my environment setup, so I created a brand new V0 account and setup a new project with just a login page. To my surprise, I get the same error in this new project on the new account.

What can I possibly do to make the Google login work?

I get these 2 errors in the console:

**1-993471bbbb25fde6.js:1 Error: [unenv] crypto.createHash is not implemented yet!**
    at n (esm.sh/node/crypto.mjs:1:22)
   (shortended for readablitity)

**1411-993471bbbb25fde6.js:1 [next-auth][error][CLIENT_FETCH_ERROR]** 
https://next-auth.js.org/errors#client_fetch_error Failed to execute 'json' on 'Response': Unexpected token 'I', "Internal s"... is not valid JSON {error: {…}, url: '/api/auth/providers', message: `Failed to execute 'json' on 'Response': Unexpected token 'I', "Internal s"... is not valid JSON`}
window.console.error @ 1411-993471bbbb25fde6.js:1
console.<computed> @ VM691 2309-3b500fa079838e7a.js:1
    (shortended for readablitity)
1411-993471bbbb25fde6.js:1 TypeError: Cannot read properties of undefined (reading 'searchParams')
    (shortended for readablitity)TypeError: Cannot read properties of undefined (reading 'searchParams')
    at et (index.js:55:48)
    (shortended for readablitity)

Hey, Emil :wave: Happy Monday!

I asked v0 to dig deeper on the error logs and it came back with some clues:

Error: [unenv] crypto.createHash is not implemented yet!

This error suggests that there’s an issue with the crypto module, which is often used in authentication processes. This could be related to how the environment is set up in the v0 workspace.

[next-auth][error][CLIENT_FETCH_ERROR]

This error indicates that there’s a problem with NextAuth.js trying to fetch the list of providers. The response it’s receiving is not valid JSON, which suggests there might be an issue with your API route for authentication providers.

TypeError: Cannot read properties of undefined (reading 'searchParams')

This error typically occurs when trying to access the ‘searchParams’ property of an undefined object, which could be related to how the URL is being handled in your authentication flow.

It’s worth checking your NextAuth.js configuration and verifying environment variables are correctly set.

Hi Pauline

Thanks for answering.

I’ve tried setting up multiple projects and get the same error, even though I’m pretty confident that I’m putting in the correct Environment Variables. On my latest project I get this error [next-auth][error][CLIENT_FETCH_ERROR].

It’s wierd because in my first project auth worked immediately after asking for a login page and putting in the variables. I’m very frustrating and don’t know what to do.

Could you provide me with some sample code, perhaps with some test variables, that I could try pasting into my own project? Or could we figure out some other solution?

Best,
Emil

Hi Pauline

Is there any suggested solutions to this?