Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rate limit to all api endpoints #5

Closed
Luitame opened this issue Jun 27, 2022 · 1 comment
Closed

Add rate limit to all api endpoints #5

Luitame opened this issue Jun 27, 2022 · 1 comment

Comments

@Luitame
Copy link
Owner

Luitame commented Jun 27, 2022

To avoid some DoS attacks, please add a rate limit to all endpoints.

@Luitame
Copy link
Owner Author

Luitame commented Jun 27, 2022

Laravel 9 already brings it by default, you can find it out on the RouteServiceProvider.php file

    /**
     * Configure the rate limiters for the application.
     *
     * @return void
     */
    protected function configureRateLimiting()
    {
        RateLimiter::for('api', function (Request $request) {
            return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip());
        });
    }

@Luitame Luitame closed this as completed Jun 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant