From c8f771c807def3b257cd12bed4579809bbfde536 Mon Sep 17 00:00:00 2001 From: Tanya Byrne Date: Tue, 25 Aug 2020 20:21:06 +0100 Subject: [PATCH] Only use rate limiter if rate_limit enabled set to true --- api/src/app.ts | 4 +++- api/src/cli/utils/create-env/index.ts | 7 ++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/api/src/app.ts b/api/src/app.ts index 56738b8b0b..8143cbb8f5 100644 --- a/api/src/app.ts +++ b/api/src/app.ts @@ -68,7 +68,9 @@ if (env.NODE_ENV !== 'development') { } // use the rate limiter - all routes for now -app.use(rateLimiter); +if (env.RATE_LIMIT_ENABLED === 'true') { + app.use(rateLimiter); +} app.use('/auth', authRouter) .use(authenticate) diff --git a/api/src/cli/utils/create-env/index.ts b/api/src/cli/utils/create-env/index.ts index fb30e99e31..3464ec304d 100644 --- a/api/src/cli/utils/create-env/index.ts +++ b/api/src/cli/utils/create-env/index.ts @@ -26,9 +26,10 @@ const defaults = { STORAGE_LOCAL_ROOT: './uploads', }, rateLimits: { - REDIS_HOST: '127.0.0.1', - REDIS_PORT: '6379', - REDIS_PASSWORD: null, + RATE_LIMIT_ENABLED: true, + SREDIS_HOST: '127.0.0.1', + SREDIS_PORT: '6379', + SREDIS_PASSWORD: null, RATE_LIMIT_TYPE: 'redis', CONSUMED_POINTS_LIMIT: 5, CONSUMED_RESET_DURATION: 1,