-
-
Notifications
You must be signed in to change notification settings - Fork 717
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Does not work in NextJS edge middleware #477
Comments
Sounds like it's a restriction of Edge Runtime. It should probably do this by default, but for an environment in which you know that Function.prototype.bind exists, you can replace |
See vercel/next.js#52009 for that fix. |
Thanks for pointing me in the right direction! Here is what I did to get this working in NextJS:
module.exports = Function.bind;
module.exports = {
// ...
webpack: (config, context) => {
if (context.nextRuntime === "edge") {=
// Assuming the function-bind.cjs file is in your
// NextJS project root.
config.resolve.alias["function-bind$"] =
require.resolve("./function-bind.cjs");
}
return config;
},
}; When using ESM for import { createRequire } from 'module';
const require = createRequire(import.meta.url);
export default {
// ...
webpack: (config, context) => {
if (context.nextRuntime === "edge") {=
// Assuming the function-bind.cjs file is in your
// NextJS project root.
config.resolve.alias["function-bind$"] =
require.resolve("./function-bind.cjs");
}
return config;
},
}; |
Using the
qs
library or any other module that depends onqs
for that matter does not work when importing in a NextJS edge middleware.It results in the following error message:
I have created a tiny demo project that depicts this problem: https://codesandbox.io/p/sandbox/affectionate-turing-hy2rwl
The text was updated successfully, but these errors were encountered: