From be2c8b34ff3714e32be00127167e452da92163f0 Mon Sep 17 00:00:00 2001 From: erenfn Date: Sat, 21 Dec 2024 01:16:59 +0300 Subject: [PATCH] activated ip check only if the env var is true --- backend/.env | 1 + backend/.env.production | 1 + backend/.env.test | 1 + backend/src/server.js | 4 +++- 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/backend/.env b/backend/.env index 3cdfaaac..b1057599 100644 --- a/backend/.env +++ b/backend/.env @@ -19,6 +19,7 @@ TEST_DB_NAME=onboarding_db_test TEST_DB_HOST=localhost TEST_DB_PORT=5432 +ENABLE_IP_CHECK=false # Allowed IP range for the API "baseIp/rangeStart-rangeEnd" (e.g. 192.168.1/1-255) separated by comma ALLOWED_IP_RANGE=11.22.33/10-200, 192.168.65/1-255 # Allowed IP addresses for the API separated by comma diff --git a/backend/.env.production b/backend/.env.production index ec404c01..7de5ae9b 100644 --- a/backend/.env.production +++ b/backend/.env.production @@ -10,6 +10,7 @@ PROD_DB_PORT=5432 # JWT Secret Key JWT_SECRET=your_prod_jwt_secret_key_here +ENABLE_IP_CHECK=false # Allowed IP range for the API "baseIp/rangeStart-rangeEnd" (e.g. 192.168.1/1-255) separated by comma ALLOWED_IP_RANGE=11.22.33/10-200 # Allowed IP addresses for the API separated by comma diff --git a/backend/.env.test b/backend/.env.test index 09be3c11..7507a9c6 100644 --- a/backend/.env.test +++ b/backend/.env.test @@ -14,6 +14,7 @@ POSTGRES_DB=onboarding_db_test # JWT Secret Key JWT_SECRET=your_test_jwt_secret_key_here +ENABLE_IP_CHECK=false # Allowed IP range for the API "baseIp/rangeStart-rangeEnd" (e.g. 192.168.1/1-255) separated by comma ALLOWED_IP_RANGE=11.22.33/10-200, 192.168.65/1-255 # Allowed IP addresses for the API separated by comma diff --git a/backend/src/server.js b/backend/src/server.js index 5d181294..356e709b 100644 --- a/backend/src/server.js +++ b/backend/src/server.js @@ -31,7 +31,9 @@ app.use(cors()); app.use(helmet()); app.use(bodyParser.json({ limit: MAX_FILE_SIZE })); app.use(jsonErrorMiddleware); -app.use(ipFilter); +if (process.env.ENABLE_IP_CHECK === 'true') { + app.use(ipFilter); +} // app.use(fileSizeValidator); const { sequelize } = require("./models");