Search code examples
middlewarestrapikoa

How to configure internal middlewares for strapi v4?


I was faced with this issue,

take for instance you want to configure strapi::cors middleware. according to the documentation we do

{
resolve: ‘strapi::cors’,
config: {
origin: [‘host1’, ‘host2’],
},
}

this won't work.


Solution

  • Use "name" property like this.

    {
    name: ‘strapi::cors’,
    config: {
    origin: [‘host1’, ‘host2’],
    },
    }
    

    If it help you, vote up.