Hello, I've been struggling to make the setup for Next.js with Edge Functions work. When following the new Next.js setup instructions, using a session guard for an API route works until that route is an edge funtion.
To reproduce I updated the example you have linked and added
export const runtime = 'edge';
to the user route
https://github.com/supertokens/next.js/blob/canary/examples/with-supertokens/app/api/user/route.ts
This now causes the error
Module not found: Can't resolve 'zlib'
(same for
querystring
and
crypto
). e.g. when running in dev or even during build. Which i think is strange since the middleware uses withSession without issues an is supposed to be the same edge runtime.
The only "workaround" I found was to tell webpack to stop polyfilling (with config below). But that breaks things elsewhere. Have you (or someone else in here) had similar experiences or a better solution? Any recommendations going forward for Next.js Edge Functions?
const nextConfig = {
webpack(config) {
config.resolve.fallback = {
...config.resolve.fallback,
crypto: false,
querystring: false,
zlib: false,
};
return config;
},
}