简体   繁体   中英

Limit Number of Requests for an IP in Strapi

I have a strapi app in which there is a collection called Page and I want to limit the number of requests to /pages . I know there is a rateLimit middleware but how do i use it and change its default limit interval and max values.

Strapi Version: 4.5.1 Operating System: Windows 11 Database: postgres

You already know there is a middleware implemented, as to how to use it. You would add this middleware to the routes . As an example:

// path: ./src/api/restaurant/routes/restaurant.js

const { createCoreRouter } = require('@strapi/strapi').factories;

module.exports = createCoreRouter('api::restaurant.restaurant', {
  config: {
    find: {
      middlewares: [
        // point to a registered middleware
        'plugin::users-permissions.rateLimit ', 
      ]
    }
  }
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM