How to apply policy to all default routes

System Information
  • Strapi Version: 4.3.6
  • Operating System: Linux
  • Database: Postgres
  • Node Version: 16.17
  • NPM Version:
  • Yarn Version: 1.22.19

Hey folks,

I do have my own global policy, which I wrote myself, which should apply to every default route, which are created by the createCoreRouter. But I don’t want to write out every route manually, since I don’t want to configure anything else on the route.
Is this even possible? I didn’t found anything in the docs.

Otherwise I would need to configure any route like this:

 module.exports = {
     routes: [
         method: 'GET',
         path: '/restaurants',
         handler: 'Restaurant.find',
         config: {
          // This should be configured globally for every route
           policies: ['global::is-allowed-to-view'] 


Hello @erdarur

Global policies - are available globally and can be accessed from everywhere(any API, any plugin). But these are not applied globally to all routes by default.

Since there is no legacy method to apply policies globally, I would recommend to use middlewares, since these can be applied at the application level to all routes, create it at ./src/middlewares/ (not in the API or plugin).