1

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.

user3531900
  • 311
  • 4
  • 13
  • 1
    Hi, did you find a solution to this? Thanks – eccebombo Feb 24 '22 at 09:17
  • Does this answer your question? [Error ServerMiddleware should expose a handle nuxt](https://stackoverflow.com/questions/63547656/error-servermiddleware-should-expose-a-handle-nuxt) – bassplayer7 Oct 19 '22 at 18:08

0 Answers0