-
Notifications
You must be signed in to change notification settings - Fork 2
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
refactor: extract next-auth
into middleware
#1
Conversation
Hi @balazsorban44 :) I made the next-auth logic so apparent on express routes to show to others if they want to drop next-auth in their respective frameworks and replicate the same changes easily. But it'd be awesome to have an Thank you for matching the exact routes, haha! Thank you so much!! 👍🏼 |
The only reference I found to fetch (that isn't in https://www.github.com/nextauthjs/next-auth/tree/main/src%2Flib%2Flogger.js The logger file is imported both client and server side. I havent thoroughly checked your code, so I might have missed something. |
Then something must have triggered the logger function and caused the fetch error during my dev. |
@balazsorban44 |
Yes, I was suspecting it comes from the |
Yeah, that discussion makes sense. There's no need for a network call when operating server-side. Until next-auth makes modifications, I'll push a polyfill. |
Hi @nextauthjs maintainer here.
This is just a suggestion, but I extracted the
NextAuth
code into its own file, so the usage API matches the one we recommend when using with Next.js as well.What do you think?
That new file could actually now be distributed something like
@next-auth/express-middleware
.I narrowed down the paths that
next-auth
should handle by sending anything else thanPOST
orGET
further withnext()
, and only match very specific URLs as documented at https://next-auth.js.org/getting-started/rest-apiI did not see a reason to import
isomorphic-fetch
, but I might have overlooked something. All the URLs I tested worked (didn't do a thorough job 😅)Happy to add it back if there is a good reason for it. 🙂