Overriding Strapi middleware #6476

This discussion has been migrated from our Github Discussion #6476

negati-ve205d ago

Strapi middleware documentation states that to over ride a default/core middleware
all one needs to do is drop that middleware into your app at ./middlewares/

and modify the middleware as needed

I tried to over ride the responseTime middleware as per the documentation and placed the responseTime middleware from node_modules/strapi/lib/middlewares/responseTime to ./middlewares/responseTime
and made simple edits to the responseTime middleware

but the changes do not get reflected on the app

what am I missing?
help much appreciated!

I’m on the latest Strapi 3.0.1 mysql

Responses to the discussion on Github

guillermodoghel139d ago


same question here!
Im trying to override the core logger middleware in order to do some custom format to get some tags in graylog

Running strapi 3.1.3

derrickmehaffy138d ago


Hello @negati-ve @guillermodoghel

Currently it is not possible to override a default middleware coming from the core packages. In this case you will need to disable the core middleware in the ./config/middleware.js using something like this:

module.exports = { settings: { responseTime: { enabled: false }, responseTimeNew: { enabled: true } } }

And create a new middleware with a different name in the ./middlewares folder and enable that.

guillermodoghel138d ago

that worked