Closed sharmapukar217 closed 2 years ago
I see. I'll be away from my computer for a few days but I'll fix it as soon as possible when I'm back. Thanks for reporting.
One more thing, while using modules like argon2 for vercel and netlify adapter( i haven't tried other), i get error couldn't load .node file. Its similar to the one which i get while using nodejs core nodules with edge run-time on nextjs.
For the second problem, I'm working on a solution that will enable us to polyfill some core Node modules. But of course it adds quite a bit of overhead, edge runtimes are simply not compatible with Node. Finding native replacements would be much better.
Native modules (.node) will never be available on the edge but for Vercel and Netlify serverless, it should be possible. I'll investigate how Next.js handles it.
Workaround for runtimes that don't support top-level await
. Replace the relevant bits in the session example with something like this to eliminate the need for top-level await:
let sessionMiddleware: ReturnType<typeof session>;
const keysPromise = EncryptedCookieStore.generateKeysFromBase64(
base64Key.split(",") as [string, ...string[]],
);
export default createRequestHandler({
middleware: {
beforePages: [
cookie(),
async (ctx) => {
if (!sessionMiddleware) {
sessionMiddleware = session({
store: new EncryptedCookieStore(await keysPromise),
defaultSessionData: {
cart: [],
},
cookieOptions: {
httpOnly: true,
secure: import.meta.env.PROD,
path: "/",
maxAge: 60 * 60 * 1000, // 1 week
},
});
}
return sessionMiddleware(ctx);
},
],
},
});
(I'll check whether Vercel really doesn't support top-level await when I have more time)
well this one is working for me so i'm closing this issue for now
Great, I'll update the example like this so it doesn't require top-level await
. I'll see about Vercel later, with a lower priority.
✘ [ERROR] Top-level await is currently not supported with the "cjs" output format.. This is only shown when i set the adapter to values other than nodejs