Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions create-a-container/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,16 @@ async function main() {
});
app.use(express.static('public'));

// We rate limit unsucessful (4xx/5xx statuses) to only 10 per 5 minutes, this
// We rate limit unsuccessful (4xx/5xx statuses, excluding 404) to only 10 per 5 minutes, this
// should allow legitimate users a few tries to login or experiment without
// allowing bad-actors to abuse requests.
// allowing bad-actors to abuse requests. 404s are excluded because browsers
// (especially Safari) automatically request favicon/apple-touch-icon paths that
// don't exist, and those harmless misses should not burn the rate-limit budget.
app.use(RateLimit({
windowMs: 5 * 60 * 1000,
max: 10,
skipSuccessfulRequests: true,
requestWasSuccessful: (req, res) => res.statusCode < 400 || res.statusCode === 404,
}));

// Set version info once at startup in app.locals
Expand Down
Loading