I am registering a serverMiddleware using a custom module like this in module.js file
const middleware = require('./utils');
this.nuxt.hook('render:setupMiddleware', app => {
this.addServerMiddleware(middleware(app));
})
Here middleware function is imported from a separate file utils/index.js which looks like this
module.exports = function(app){
app.use('/test', (req, res, next) => {
/*doing some stuff here*/
});
}
While running the application it gives the error
ServerMiddleware should expose a handle: undefined
If i register utils/index.js file using nuxt.config.js file like this then it works fine
serverMiddleware: [
'custome_module/utils/index',
],
Please suggest how it can be registered using module.js file.