Im using the better-auth in a non-nextjs server to verify session and see this error.

error Cannot find module '/app/node_modules/next/headers' imported from /app/node_modules/better-auth/dist/integrations/next-js.cjs Did you mean to import "next/headers.js"?
2 Replies
Sebastian
SebastianOP17h ago
how can I fix this? Seems like better-auth it's trying to import next/headers in a non next-js environment. This should not happen
Terasumi
Terasumi15h ago
just pass headers to it. for example this hono's header:
const session = await auth(db, c.env).api.getSession({
headers: c.req.raw.headers,
});
const session = await auth(db, c.env).api.getSession({
headers: c.req.raw.headers,
});

Did you find this page helpful?