How to setup rate limit for /api/

The rate limit policy has now been changed to a middleware.

The ratelimit.js can now be found here:

See the example of ratelimit middleware usage from a plugin extension below:

    plugin.routes['content-api'].routes.push({
        method: 'GET',
        path: '/auth/passwordless',
        handler: 'auth.passwordless',
        config: {
            // policies: ['plugins::users-permissions.ratelimit'], (deprecated) 
            middlewares: ['plugin::users-permissions.rateLimit'],
            prefix: '',
        },
    })
1 Like