This replaces require_optional in next-auth with one which loads mongodb
module.
This fix needed so MongoDB can be used as storage provider in next-auth, see nextauthjs/next-auth#887
Add this to next.config.js
module.exports = {
webpack: (config) => {
config.resolve.alias = {
...config.resolve.alias,
require_optional: "[email protected]",
};
return config;
},
};
Add this to package.json
"dependencies": {
...
"require_optional": "[email protected]",
...
}