While deploying - A Node.js API is used (process.exit at line: 1451) which is not supported in..

While deploying my next.js app on vercel it's giving this error ./node_modules/better-auth/dist/chunk-62MWLLEG.js A Node.js API is used (process.exit at line: 1451) which is not supported in the Edge Runtime. Learn more: https://nextjs.org/docs/api-reference/edge-runtime
8 Replies
bekacru
bekacru3d ago
better auth doesn't work on edge
joseph013318
joseph013318OP2d ago
How to resolve the issue? I am deploying in vercel with better-auth as authentication
lonelyplanet
lonelyplanet2d ago
most likely your either setting the runtime to edge in a route with export const runtime = 'edge'; along with using better auth which doesnt work. or your using better-auth in you middleware.ts @joseph013318 Read up what the edge runtime is and also how nextjs middleware works
Ping
Ping2d ago
most likely either a export const runtime = 'edge';
Better Auth doesn't work on edge.
lonelyplanet
lonelyplanet2d ago
I know? Im saying that mostly likely the issue?
Ping
Ping2d ago
I missunderstood you, sorry.
joseph013318
joseph013318OP16h ago
@Ping @lonelyplanet Yes using it in middleware. This is the exact code I used as in the better-auth docs https://www.better-auth.com/docs/integrations/next#middleware I need protected routes with auth! How do I solve the issue?
Next.js integration | Better Auth
Integrate Better Auth with Next.js.
lonelyplanet
lonelyplanet15h ago
Care to share your middleware?

Did you find this page helpful?