Different middlewares settings based on NODE_ENV?

Is there a way to use different middlewares settings for development and production in Strapi?

I have set up Postgres and AWS S3 for use in production, but would like to use Sqlite and the local filesystem in development. For the database.js it is no issue, but as the middlewares.js exports an array, I am not sure how to handle it there. Also, I cannot find anything in the docs on how to solve it.

Has anyone got any suggestions?

System Information
  • Strapi Version: 4
  • Operating System: Digitalocean App Platform
  • Database: Postgres
  • Node Version: 17
  • NPM Version: 8
  • Yarn Version: -

I guess you can use and if statement and say

if(process.env.NODE_ENV === "X") {
// do stuff
} else {
// do other stuff
1 Like

Thanks, that worked. Should probably have thought of that, no clue why I didn’t (ー_ー﹡; )