From fce6dee23b3ec8d26c9d3d323b28eeeab03319cd Mon Sep 17 00:00:00 2001 From: Jonathan Harden Date: Thu, 5 Sep 2024 15:29:07 +0100 Subject: [PATCH] PP-13145: Bind to localhost by default instead of 0.0.0.0 --- README.md | 1 + server.js | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b1e84d411..53b91cead 100644 --- a/README.md +++ b/README.md @@ -97,6 +97,7 @@ Run in two separate terminals: | variable | required | default value | Description | |:---------------------------------------|:--------:|:-------------------------------------------------------------:|:------------------------------------------------------------------------------------------------------------------------------------------------------| +| `BIND_HOST` | | 127.0.0.1 | The IP address for the application to bind to. | | `PORT` | X | 9200 | The port number for the express server to be bound at runtime | | `SESSION_ENCRYPTION_KEY` | X | | key to be used by the cookie encryption algorithm. Should be a large unguessable string ([More Info](https://www.npmjs.com/package/client-sessions)). | | `CONNECTOR_TOKEN_URL` | X | | The connector endpoint to use when validating the one time token. | diff --git a/server.js b/server.js index bf19c1a15..0cf996994 100644 --- a/server.js +++ b/server.js @@ -30,6 +30,7 @@ const { requestContextMiddleware } = require('./app/services/clients/base/reques const { NODE_ENV, PORT, + BIND_HOST, ANALYTICS_TRACKING_ID, GOOGLE_PAY_MERCHANT_ID, WORLDPAY_APPLE_PAY_MERCHANT_ID_CERTIFICATE, @@ -160,8 +161,10 @@ function setNoCacheHeadersForRoutes (app) { function listen () { const app = initialise() - app.listen(PORT || 3000) - logger.info('Listening on port ' + PORT || 3000) + const DEFAULT_PORT = 3000 + const DEFAULT_BIND_HOST = "127.0.0.1" + app.listen(PORT || DEFAULT_PORT, BIND_HOST || DEFAULT_BIND_HOST) + logger.info(`Listening on ${BIND_HOST || DEFAULT_BIND_HOST}:${PORT || DEFAULT_PORT}`) } function logApplePayCertificateTimeToExpiry () {