Limiter les Requêtes Répétées
You are reading the documentation for version 2 of FoalTS. Instructions for upgrading to this version are available here. The old documentation can be found here.
To prevent brute force attacks or overloads on your application, you need to implement a rate limiter to limit the number of requests a user is able to send to your application.
In FoalTS you can implement a rate limiter like the express-rate-limit package by creating a customized express
object and passing it as a parameter to the FoalTS createApp
function.
Note: Because the rate limiter response for rate limited requests does not get handled by FoalTS and its hooks, you need to manually set the default FoalTS headers to the response object of the rate limiter in its
handle
function. If you don't manually set any headers only the default Express.js headers will be set in the response.
src/index.ts
#
Rate limiting with CORSIf you need CORS headers in a rate limited response, you will need to manually add the headers in the rate limiter handler
function accordingly.
You can find more options for express-rate-limit in the documentation.