mickasmt / next-saas-stripe-starter

Open-source SaaS Starter with User Roles & Admin Panel. Built using Next.js 14, Prisma, Neon, Auth.js v5, Resend, React Email, Shadcn/ui, Stripe, Server Actions.
https://next-saas-stripe-starter.vercel.app
MIT License
1.95k stars 354 forks source link

Google login failed #35

Closed addlistener closed 5 months ago

addlistener commented 5 months ago

As described in this thread. It's just a really simple client id & secret, what could go wrong...

https://github.com/nextauthjs/next-auth/issues/10089#issuecomment-2156593632

image
[auth][error] TypeError: fetch failed
    at Object.fetch (node:internal/deps/undici/undici:11730:11)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at getAuthorizationUrl (webpack-internal:///(rsc)/./node_modules/next-auth/node_modules/@auth/core/lib/actions/signin/authorization-url.js:24:35)
    at Module.signIn (webpack-internal:///(rsc)/./node_modules/next-auth/node_modules/@auth/core/lib/actions/signin/index.js:16:56)
    at AuthInternal (webpack-internal:///(rsc)/./node_modules/next-auth/node_modules/@auth/core/lib/index.js:72:24)
    at Auth (webpack-internal:///(rsc)/./node_modules/next-auth/node_modules/@auth/core/index.js:126:34)
    at /path/to/my-saas-project/node_modules/next/dist/compiled/next-server/webpack:/next/dist/esm/server/future/route-modules/app-route/module.js:207:37
    at e_.execute (/path/to/my-saas-project/node_modules/next/dist/compiled/next-server/webpack:/next/dist/esm/server/future/route-modules/app-route/module.js:122:26)
    at e_.handle (/path/to/my-saas-project/node_modules/next/dist/compiled/next-server/webpack:/next/dist/esm/server/future/route-modules/app-route/module.js:269:30)
    at doRender (/path/to/my-saas-project/node_modules/next/src/server/base-server.ts:2273:30)
mickasmt commented 5 months ago

Hi @addlistener I updated the auth part in the docs. You can find a video explanation and my google config for this repo. Its based on the v5. In the other thread you checked the v4 docs. Some bugs may appear if you don't remove NEXTAUTH_URL in your .env file. Let me know if it works after this.

addlistener commented 5 months ago

Hi @addlistener I updated the auth part in the docs. You can find a video explanation and my google config for this repo. Its based on the v5. In the other thread you checked the v4 docs. Some bugs may appear if you don't remove NEXTAUTH_URL in your .env file. Let me know if it works after this.

@mickasmt thank you so much for the quick response!

In fact I created this app using the recommended npx create-next-app my-saas-project --example "https://github.com/mickasmt/next-saas-stripe-starter" yesterday.

I don't have NEXTAUTH_URL in my .env file

image

And I'm using v5 next-auth

  next-auth@5.0.0-beta.18:
    resolution: {integrity: sha512-x55L8wZb8PcPGCYA3e/l9tdpd7YL3FDuhas4W8pxq3PjrWJ9OoDxNN0otK9axJamJBbBgjfzTJjVQB6hXoe0ZQ==}

And I did went through your video https://www.youtube.com/watch?v=1MTyCvS05V4&t=12270s here. My config on google.

image

So I guess it's probably next-auth v5 or the google new oauth workflow? Basically they are both just upgraded and not stable enough.

addlistener commented 5 months ago

I guess this is what I'm actually experiencing. A lot of people are bugged with this

https://github.com/nextauthjs/next-auth/issues/3920 https://github.com/nextauthjs/next-auth/issues/2509#issuecomment-1035410802

I just deployed on vercel and the request went through.

AlanGolphi commented 4 months ago

I met the same problem and also cannot work in my localhost, only after I deploy to vercel and it work

do you have any solution for develop in localhost? please mention me, thanks very much