mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 03:19:46 +00:00
Don't include ratelimit headers on the default bucket
This commit is contained in:
parent
3fdd6e2213
commit
8083148d03
2 changed files with 3 additions and 2 deletions
|
|
@ -178,7 +178,7 @@ const publicFiles = serveStatic({ root: './public/' });
|
|||
const staticFiles = serveStatic({ root: './static/' });
|
||||
|
||||
app.use('*', cacheControlMiddleware({ noStore: true }));
|
||||
app.use('*', rateLimitMiddleware(300, Time.minutes(5)));
|
||||
app.use('*', rateLimitMiddleware(300, Time.minutes(5), false));
|
||||
|
||||
app.use('/api/*', metricsMiddleware, paginationMiddleware, logger(debug));
|
||||
app.use('/.well-known/*', metricsMiddleware, logger(debug));
|
||||
|
|
|
|||
|
|
@ -4,11 +4,12 @@ import { rateLimiter } from 'hono-rate-limiter';
|
|||
/**
|
||||
* Rate limit middleware for Hono, based on [`hono-rate-limiter`](https://github.com/rhinobase/hono-rate-limiter).
|
||||
*/
|
||||
export function rateLimitMiddleware(limit: number, windowMs: number): MiddlewareHandler {
|
||||
export function rateLimitMiddleware(limit: number, windowMs: number, includeHeaders?: boolean): MiddlewareHandler {
|
||||
// @ts-ignore Mismatched hono versions.
|
||||
return rateLimiter({
|
||||
limit,
|
||||
windowMs,
|
||||
standardHeaders: includeHeaders,
|
||||
handler: (c) => {
|
||||
c.header('Cache-Control', 'no-store');
|
||||
return c.text('Too many requests, please try again later.', 429);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue