Next.js Discord

Discord Forum

Need hep to fix error on route protection by customizing the middleware in NextAuth.

Answered
Ghostman posted this in #help-forum
Open in Discord
Hi there,

When I try Middleware Route Protection in my Next.js NextAuth with Drizzle, I got errors like followings.

cloudflare:sockets
Module build failed: UnhandledSchemeError: Reading from "cloudflare:sockets" is not handled by plugins (Unhandled scheme).
Webpack supports "data:" and "file:" URIs by default.
You may need an additional plugin to handle "cloudflare:" URIs.
Import trace for requested module:
cloudflare:sockets
./node_modules/postgres/cf/polyfills.js
./node_modules/postgres/cf/src/index.js
./database/index.ts
./auth.ts


Here is my middleware.ts file
export { auth as middleware } from './auth';

export const config = {
  matcher: ['/((?!api|_next/static|_next/image|favicon.ico).*)'],
};


FYI: I'm using next14.1.3, next-auth 5.0.0-beta.15
If I remove middleware.ts file from my project, it's working fine.

I tried several solutions but could not solve this problem. Please help me 🙏
Answered by averydelusionalperson
View full answer

9 Replies

Answer
Hey @Ghostman, did you found the solution?
Yes, I found it
so, can you close this thread, by marking your message as solution. if my messages didn't help.
Thank you
your welcome, so can you mark the message as solution.
Original message was deleted
^
🫡