Skip to content

Commit

Permalink
Merge pull request #3900 from alphagov/pp-13145/bind-to-localhost-by-…
Browse files Browse the repository at this point in the history
…default

PP-13145: Bind to localhost by default instead of 0.0.0.0
  • Loading branch information
jfharden committed Sep 5, 2024
2 parents 8579955 + fce6dee commit 80a67f4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. |
Expand Down
7 changes: 5 additions & 2 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 () {
Expand Down

0 comments on commit 80a67f4

Please sign in to comment.