Next.js Discord

Discord Forum

Is it possible to use NextAuth with Cloudflare Pages edge runtime

Unanswered
Chilean jack mackerel posted this in #help-forum
Open in Discord
Chilean jack mackerelOP
I recently tried to deploy my project with NextAuth into Cloudflare Pages but while building I got an error that I need to add
export const runtime = 'edge';

into my /api/auth/[...nextauth] path, but when I do that I get an error It can't find crypto package, so It has problems with edge runtime. Is it possible to make it work?

9 Replies

Chilean jack mackerelOP
I know but is it possible to make it work on edge somehow, I read some posts about it and about experimental build of next-auth but I'm not sure
https://nextjs.org/learn
this course has shown how to use next-auth v5 on edge
Chilean jack mackerelOP
are there any docs or info about how to migrate to next-auth v5 ?
Chilean jack mackerelOP
Well, okay, I did, but now I'm experiencing a weird error with my access_token from the Spotify provider. Earlier in version 4 I was able to get access_token and send requests from it but now I get access_token and after 1 request the access_token seems blocked and I get a 403 return from their API with no content. I've checked it and it's about quota, and adding users to the list of restricted users would fix the problem, but it's not. Also now, every time I click the login button, I have to confirm the authorization on the Spotify website, but in version 4 I didn't have to. Has anyone else had this error too?
Chilean jack mackerelOP
Okay I just found out that scopes in authorization process are not being passed in v5
okay I fixed it and this is issue related to my problem