-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cloudflare Workers Support #725
Comments
Unfortunately not. CloudFlare Workers are missing features required by Next.js and common node modules required by Next.js and NextAuth.js. While highly cost effective in some scenarios in practice I've found the workers are limited to use for bespoke functions written explicitly with them in mind. However, you can use them in tandem with a Next.js app which uses NextAuth.js that deployed somewhere else to do something like read and validate a JWT to determine if a user should be returned content (that's a GREAT use case!) but you couldn't deploy a Next.js or NextAuth.js app as a CloudFlare Worker directly. If you are looking at similar technologies, it is also possible to deploy Next.js and NextAuth.js to AWS Lambda @ Edge - though it's a little trickier to deploy than to a regular AWS Lambda (and in turnthat more involved than deploying to Vercel or Heroku or with Docker). Lambda @ Edge instances are similar to AWS Lambda but with some limitations (memory, CPU and environment variables need to be baked in); like CloudFlare Workers they run at the Edge, but on the AWS CloudFront CDN. |
Closing this one as we've answer the question as best we can. Happy to respond to any follow up questions! |
Thank you. |
@iaincollins I'm trying to implement this. Here are my concerns. I need to make a few calls to the DB and process the data, which occasionally might take more than 10s, thus resulting in a timeout on Vercel. Hence I'm I'd like to have the API external and have the client directly call the external API, so the timeout issue can be overcome. But now the external API need to validate the requests from the client. I tried to find out how to validate the JWT, but it looks like the client doesn't have access to the raw token and can only the data can be accessed via useSession(). How should I go about in this situation? Or are there any flaws in my understanding so for? Thanks in advance! |
NextJS Now supports running api routes on Cloudflare workers. Can we get this re-opened @iaincollins |
@iaincollins ^^ reopen? |
Now we have @auth/core, is this possible? |
Any updates here? |
I got it to work. I can make a sample repository by tomorrow |
Thanks so much! You're a lifesaver |
@Pelps12 Could you share how you did it please? I'm hitting this with Cloudflare Pages. |
I'd love to get next-auth running on cloudflare. Just tried the next-auth example app (https://github.com/nextauthjs/next-auth-example) with the suggested changes and instructions for next apps on cloudflare: https://github.com/cloudflare/next-on-pages I hit the wall here:
Any help with this would be highly appreciated. Btw, |
@Pelps12 I would appreciate it if you could share the repo. |
@Pelps12 dont tease us! |
I have been in communication with @Pelps12. Here is a repo with the core next auth functionality that I built. You will need to set up your adapter & finish the provider, but this should take you part of the way there. I will finish this when I have some more availability and I would appreciate any PRs. I can explain to someone the how if they are willing to put in the time to finish it. https://github.com/eli-front/next-auth-edge |
|
There's no integration with next yet on @auth. @auth/nextjs isn't published. Seems next-auth/core still requires things like |
You should be able to use @auth/core with next if you'd like. |
Theres no SessionProvider to put in _app in @auth/core |
It's not too bad to make your own session provider. It's just a GET to |
@balazsorban44 Would you consider re-opening this? it seems there is a lot of renewed interest in this topic. |
We recently announced Although experimental, As for The client-side is pretty much If you find any compatibility issues, I suggest opening a new issue, rather than commenting here. We don't monitor closed issues. Thanks! 🙏 |
Can NextAuth.js be used inside a Cloudflare Worker?
I see that the server side example for using NextAuth has the following line
export default (req, res) => NextAuth(req, res, options)
Since Cloudflare Workers do not have a node runtime, I was wondering if the req and res objects would work inside a Cloudflare Worker. If not is there a work around that you can suggest? Thank you.
The text was updated successfully, but these errors were encountered: