Better Auth (auth.api.getSession) causes problem in edge runtime
Hey everyone, I am new to using Better Auth. I am using a middleware to call auth.api.getSession() to check if the user is authenticated:
• It grabs the current request headers (cookies, tokens, etc.). • Passes them to auth library (likely better-auth or next-auth) to fetch the current session. • If no session exists, it redirects the user to /sign-in. • Otherwise, it allows the request to continue.
But I am getting the following error:
2025-05-20T20:02:11.555Z ERROR [Better Auth]: INTERNAL_SERVER_ERROR Error: The edge runtime does not support Node.js 'perf_hooks' module. Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime{ } ⨯ [Error [APIError]: Failed to get session]