Rate Limiting

Can anyone guide me on implementing rate limit. I have checked out the existing resources and blog. It doesn’t work for me

This topic has been created from a Discord post (1219655519514656809) to give it more visibility.
It will be on Read-Only mode here.
Join the conversation on Discord

1 Like

Which posts have you looked at so we can take a look and see if they need to be updated?

Also, here is what a basic implementation will look like. We are using koa2-ratelimit so refer to the https://www.npmjs.com/package/koa2-ratelimit package to see all the config options.

"use strict";

/**
 * post router
 */

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

module.exports = createCoreRouter("api::post.post", {
  config: {
    find: {
      middlewares: [
        {
          name: "plugin::users-permissions.rateLimit",
          config: {
            max: 10,
          },
        },
      ],
    },
  },
});

// https://docs.strapi.io/dev-docs/backend-customization/routes

// https://github.com/strapi/strapi/blob/main/packages/plugins/users-permissions/server/middlewares/rateLimit.js

// https://www.npmjs.com/package/koa2-ratelimit

// https://docs.strapi.io/dev-docs/backend-customization/routes#middlewares