vercel / ai-chatbot

A full-featured, hackable Next.js AI chatbot built by Vercel
https://chat.vercel.ai
Other
5.52k stars 1.63k forks source link

Can't get any next-auth email provider (magic link) to work #244

Open tomatac opened 4 months ago

tomatac commented 4 months ago

Can't get next-auth email provider to work. Because this example is using an old beta version of the next-auth (next-auth 5.0.0-beta.4) I cannot implement an additional email authentication (magic link). The SMTP mail depends on nodemailer and that cannot run at the edge. The authentication for this project is setup to run at the edge and there is not a straight forward method to change that. HTTP-based Email Provider gives a type error and it does not work: Type '"email"' is not assignable to type '"credentials" | "oidc" | "oauth"'.ts(2322) (property) type: "email". The auth/prisma-adapter required by the email provider has a dependency conflict with next-auth 5.0.0-beta.4 used on this project. @auth/prisma-adapter 1.4.0 └── @auth/core 0.27.0 next-auth 5.0.0-beta.4 └── @auth/core 0.18.4 I tried to resolve that by downgrading to @auth/prisma-adapter 1.0.9 and it still does not work: [auth][error] AdapterError: Read more at https://errors.authjs.dev#adaptererror [auth][cause]: Error: PrismaClient is unable to run in Vercel Edge Functions or Edge Middleware. As an alternative, try Accelerate: https://pris.ly/d/accelerate. If this is unexpected, please open an issue: https://pris.ly/prisma-prisma-bug-report Was anybody successful implementing authentication using an email provider (magic link)?

tomatac commented 3 months ago

Is anybody able to make next-auth email provider (magic link) work for this project?

I tried upgrading next-auth from "5.0.0-beta.4 to next-auth": "5.0.0-beta.15 but I get an error right away: "UnknownAction: Cannot parse action at /session"

tomatac commented 3 months ago

I got next-auth 5.0.0-beta.15 error resolved. See: https://github.com/nextauthjs/next-auth/issues/10309 But I still cannot get the next-auth email provider (magic link) to work. The fact that this application template is configured to run at the edge makes it quite difficult. Is there an easy way to run this application in a full NodeJS environment?

helloivanco commented 3 weeks ago

I got next-auth 5.0.0-beta.15 error resolved. See: nextauthjs/next-auth#10309 But I still cannot get the next-auth email provider (magic link) to work. The fact that this application template is configured to run at the edge makes it quite difficult. Is there an easy way to run this application in a full NodeJS environment?

Hi @tomatac were you able to get magic link working?

tomatac commented 3 weeks ago

No I could not get this to work. It was quite frustrating and I ran out of time. I ended up using an authentication provider. I would like to revisit this issue when next-auth 5.0 is released. The next-auth beta felt more like alfa.