From a540754f6e99b45f436319643ce9b843489e4a6a Mon Sep 17 00:00:00 2001 From: Jakob Ackermann Date: Thu, 25 Apr 2024 13:56:00 +0100 Subject: [PATCH] Merge pull request #18116 from overleaf/jpa-bulk-replace-localhost [misc] bulk replace localhost with 127.0.0.1 GitOrigin-RevId: d238f3635302e8ff5500d611108c4d1bef216726 --- .../fetch-utils/test/unit/FetchUtilsTests.js | 2 +- .../redis-wrapper/test/scripts/standalone.js | 2 +- services/chat/config/settings.defaults.cjs | 6 +- .../test/acceptance/js/helpers/ChatApp.js | 2 +- .../test/acceptance/js/helpers/ChatClient.js | 2 +- services/clsi/config/settings.defaults.js | 6 +- .../clsi/test/acceptance/js/helpers/Client.js | 2 +- .../contacts/config/settings.defaults.cjs | 4 +- .../acceptance/js/GettingContactsTests.js | 4 +- services/docstore/app/js/HealthChecker.js | 2 +- services/docstore/config/settings.defaults.js | 2 +- .../test/acceptance/js/helpers/DocstoreApp.js | 2 +- .../acceptance/js/helpers/DocstoreClient.js | 22 +++--- services/document-updater/app.js | 2 +- .../config/settings.defaults.js | 16 ++--- .../acceptance/js/helpers/DocUpdaterApp.js | 2 +- .../acceptance/js/helpers/DocUpdaterClient.js | 30 ++++---- .../js/test_blpop_failover.js | 4 +- .../js/test_pubsub_failover.js | 4 +- .../filestore/config/settings.defaults.js | 2 +- .../test/acceptance/deps/Dockerfile.fake-gcs | 2 +- .../test/acceptance/deps/Dockerfile.s3mock | 2 +- .../test/acceptance/js/FilestoreApp.js | 2 +- .../test/acceptance/js/FilestoreTests.js | 2 +- .../acceptance/js/api/support/test_server.js | 2 +- services/notifications/app.js | 2 +- .../app/js/HealthCheckController.js | 2 +- .../notifications/config/settings.defaults.js | 4 +- .../project-history/app/js/HealthChecker.js | 4 +- .../config/settings.defaults.cjs | 18 ++--- .../test/acceptance/js/DeleteProjectTests.js | 4 +- .../test/acceptance/js/DiffTests.js | 6 +- .../acceptance/js/DiscardingUpdatesTests.js | 4 +- .../test/acceptance/js/FileTreeDiffTests.js | 6 +- .../test/acceptance/js/FlushManagerTests.js | 12 ++-- .../test/acceptance/js/HealthCheckTests.js | 6 +- .../test/acceptance/js/LabelsTests.js | 6 +- .../acceptance/js/ReadingASnapshotTests.js | 4 +- .../test/acceptance/js/RetryTests.js | 12 ++-- .../test/acceptance/js/SendingUpdatesTests.js | 8 +-- .../acceptance/js/SummarisedUpdatesTests.js | 6 +- .../test/acceptance/js/SyncTests.js | 10 +-- .../js/helpers/ProjectHistoryApp.js | 2 +- .../js/helpers/ProjectHistoryClient.js | 30 ++++---- .../real-time/config/settings.defaults.js | 14 ++-- .../test/acceptance/js/DrainManagerTests.js | 2 +- .../test/acceptance/js/HttpControllerTests.js | 2 +- .../acceptance/js/helpers/RealTimeClient.js | 8 +-- .../acceptance/js/helpers/RealtimeServer.js | 2 +- .../test/acceptance/libs/XMLHttpRequest.js | 6 +- services/spelling/app.js | 2 +- .../spelling/app/js/HealthCheckController.js | 2 +- .../spelling/config/settings.defaults.cjs | 2 +- services/spelling/test/acceptance/js/Init.js | 2 +- .../test/acceptance/js/helpers/request.js | 2 +- .../spelling/test/stress/js/stressTest.js | 2 +- services/web/app.js | 2 +- services/web/config/settings.defaults.js | 70 +++++++++---------- services/web/docker-compose.common.env | 4 +- services/web/local-test.env | 4 +- .../acceptance/src/ServerCEScriptsTests.js | 2 +- .../config/settings.test.defaults.js | 34 ++++----- .../acceptance/config/settings.test.saas.js | 10 +-- .../src/HttpPermissionsPolicyTests.js | 2 +- .../test/acceptance/src/LinkedFilesTests.js | 2 +- .../test/acceptance/src/helpers/UserHelper.js | 2 +- .../test/acceptance/src/helpers/request.js | 2 +- .../acceptance/src/mocks/MockV1HistoryApi.js | 2 +- services/web/test/frontend/bootstrap.js | 2 +- .../unit/src/Compile/CompileManagerTests.js | 2 +- .../unit/src/Exports/ExportsHandlerTests.js | 6 +- .../unit/src/HelperFiles/UrlHelperTests.js | 2 +- .../src/Templates/TemplatesManagerTests.js | 2 +- .../TpdsUpdateSenderTests.js | 2 +- 74 files changed, 236 insertions(+), 236 deletions(-) diff --git a/libraries/fetch-utils/test/unit/FetchUtilsTests.js b/libraries/fetch-utils/test/unit/FetchUtilsTests.js index fae8365359..280d7055b2 100644 --- a/libraries/fetch-utils/test/unit/FetchUtilsTests.js +++ b/libraries/fetch-utils/test/unit/FetchUtilsTests.js @@ -18,7 +18,7 @@ describe('fetch-utils', function () { before(async function () { this.server = new TestServer() await this.server.start(PORT) - this.url = path => `http://localhost:${PORT}${path}` + this.url = path => `http://127.0.0.1:${PORT}${path}` }) after(async function () { diff --git a/libraries/redis-wrapper/test/scripts/standalone.js b/libraries/redis-wrapper/test/scripts/standalone.js index e28d5f5f0b..1665e96275 100644 --- a/libraries/redis-wrapper/test/scripts/standalone.js +++ b/libraries/redis-wrapper/test/scripts/standalone.js @@ -4,7 +4,7 @@ const redis = require('../../') const logger = require('@overleaf/logger') -const rclient = redis.createClient({ host: 'localhost', port: '6379' }) +const rclient = redis.createClient({ host: '127.0.0.1', port: '6379' }) setInterval(() => { rclient.healthCheck(err => { diff --git a/services/chat/config/settings.defaults.cjs b/services/chat/config/settings.defaults.cjs index ec688fc128..48734ff11e 100644 --- a/services/chat/config/settings.defaults.cjs +++ b/services/chat/config/settings.defaults.cjs @@ -1,14 +1,14 @@ module.exports = { internal: { chat: { - host: process.env.LISTEN_ADDRESS || 'localhost', + host: process.env.LISTEN_ADDRESS || '127.0.0.1', port: 3010, }, }, apis: { web: { - url: `http://${process.env.WEB_HOST || 'localhost'}:${ + url: `http://${process.env.WEB_HOST || '127.0.0.1'}:${ process.env.WEB_PORT || 3000 }`, user: process.env.WEB_API_USER || 'overleaf', @@ -19,7 +19,7 @@ module.exports = { mongo: { url: process.env.MONGO_CONNECTION_STRING || - `mongodb://${process.env.MONGO_HOST || 'localhost'}/sharelatex`, + `mongodb://${process.env.MONGO_HOST || '127.0.0.1'}/sharelatex`, options: { monitorCommands: true, }, diff --git a/services/chat/test/acceptance/js/helpers/ChatApp.js b/services/chat/test/acceptance/js/helpers/ChatApp.js index 848268f516..7116ea36f6 100644 --- a/services/chat/test/acceptance/js/helpers/ChatApp.js +++ b/services/chat/test/acceptance/js/helpers/ChatApp.js @@ -9,7 +9,7 @@ export async function ensureRunning() { if (!serverPromise) { const { app } = await createServer() const startServer = promisify(app.listen.bind(app)) - serverPromise = startServer(3010, 'localhost') + serverPromise = startServer(3010, '127.0.0.1') } return serverPromise } diff --git a/services/chat/test/acceptance/js/helpers/ChatClient.js b/services/chat/test/acceptance/js/helpers/ChatClient.js index 022afecc9b..97c711f784 100644 --- a/services/chat/test/acceptance/js/helpers/ChatClient.js +++ b/services/chat/test/acceptance/js/helpers/ChatClient.js @@ -1,7 +1,7 @@ import Request from 'request' const request = Request.defaults({ - baseUrl: 'http://localhost:3010', + baseUrl: 'http://127.0.0.1:3010', }) async function asyncRequest(options) { diff --git a/services/clsi/config/settings.defaults.js b/services/clsi/config/settings.defaults.js index e89e0850a1..5af38af9c4 100644 --- a/services/clsi/config/settings.defaults.js +++ b/services/clsi/config/settings.defaults.js @@ -23,7 +23,7 @@ module.exports = { internal: { clsi: { port: 3013, - host: process.env.LISTEN_ADDRESS || 'localhost', + host: process.env.LISTEN_ADDRESS || '127.0.0.1', }, load_balancer_agent: { @@ -35,12 +35,12 @@ module.exports = { apis: { clsi: { // Internal requests (used by tests only at the time of writing). - url: `http://${process.env.CLSI_HOST || 'localhost'}:3013`, + url: `http://${process.env.CLSI_HOST || '127.0.0.1'}:3013`, // External url prefix for output files, e.g. for requests via load-balancers. outputUrlPrefix: `${process.env.ZONE ? `/zone/${process.env.ZONE}` : ''}`, }, clsiPerf: { - host: `${process.env.CLSI_PERF_HOST || 'localhost'}:${ + host: `${process.env.CLSI_PERF_HOST || '127.0.0.1'}:${ process.env.CLSI_PERF_PORT || '3043' }`, }, diff --git a/services/clsi/test/acceptance/js/helpers/Client.js b/services/clsi/test/acceptance/js/helpers/Client.js index 041518966d..389a26201e 100644 --- a/services/clsi/test/acceptance/js/helpers/Client.js +++ b/services/clsi/test/acceptance/js/helpers/Client.js @@ -72,7 +72,7 @@ module.exports = Client = { done(new Error('error starting server: ' + error.message)) } else { const addr = server.address() - Settings.filestoreDomainOveride = `http://localhost:${addr.port}` + Settings.filestoreDomainOveride = `http://127.0.0.1:${addr.port}` done() } }) diff --git a/services/contacts/config/settings.defaults.cjs b/services/contacts/config/settings.defaults.cjs index df120388b1..fb716d1812 100644 --- a/services/contacts/config/settings.defaults.cjs +++ b/services/contacts/config/settings.defaults.cjs @@ -5,14 +5,14 @@ module.exports = { internal: { contacts: { port: 3036, - host: process.env.LISTEN_ADDRESS || 'localhost', + host: process.env.LISTEN_ADDRESS || '127.0.0.1', }, }, mongo: { url: process.env.MONGO_CONNECTION_STRING || - `mongodb://${process.env.MONGO_HOST || 'localhost'}/sharelatex`, + `mongodb://${process.env.MONGO_HOST || '127.0.0.1'}/sharelatex`, options: { monitorCommands: true, }, diff --git a/services/contacts/test/acceptance/js/GettingContactsTests.js b/services/contacts/test/acceptance/js/GettingContactsTests.js index 81bc10b59b..769f7cefe7 100644 --- a/services/contacts/test/acceptance/js/GettingContactsTests.js +++ b/services/contacts/test/acceptance/js/GettingContactsTests.js @@ -3,11 +3,11 @@ import request from 'request' import async from 'async' import { app } from '../../../app/js/server.js' -const HOST = 'http://localhost:3036' +const HOST = 'http://127.0.0.1:3036' describe('Getting Contacts', function () { before(function (done) { - this.server = app.listen(3036, 'localhost', error => { + this.server = app.listen(3036, '127.0.0.1', error => { if (error != null) { throw error } diff --git a/services/docstore/app/js/HealthChecker.js b/services/docstore/app/js/HealthChecker.js index 9e4a545e5f..65dc92cbba 100644 --- a/services/docstore/app/js/HealthChecker.js +++ b/services/docstore/app/js/HealthChecker.js @@ -19,7 +19,7 @@ module.exports = { check(callback) { const docId = new ObjectId() const projectId = new ObjectId(settings.docstore.healthCheck.project_id) - const url = `http://localhost:${port}/project/${projectId}/doc/${docId}` + const url = `http://127.0.0.1:${port}/project/${projectId}/doc/${docId}` const lines = [ 'smoke test - delete me', `${crypto.randomBytes(32).toString('hex')}`, diff --git a/services/docstore/config/settings.defaults.js b/services/docstore/config/settings.defaults.js index 4f65240a19..b91cdc87ec 100644 --- a/services/docstore/config/settings.defaults.js +++ b/services/docstore/config/settings.defaults.js @@ -5,7 +5,7 @@ const Settings = { internal: { docstore: { port: 3016, - host: process.env.LISTEN_ADDRESS || 'localhost', + host: process.env.LISTEN_ADDRESS || '127.0.0.1', }, }, diff --git a/services/docstore/test/acceptance/js/helpers/DocstoreApp.js b/services/docstore/test/acceptance/js/helpers/DocstoreApp.js index f6f11932b8..03db0ea322 100644 --- a/services/docstore/test/acceptance/js/helpers/DocstoreApp.js +++ b/services/docstore/test/acceptance/js/helpers/DocstoreApp.js @@ -14,7 +14,7 @@ module.exports = { } this.initing = true this.callbacks.push(callback) - app.listen(settings.internal.docstore.port, 'localhost', error => { + app.listen(settings.internal.docstore.port, '127.0.0.1', error => { if (error != null) { throw error } diff --git a/services/docstore/test/acceptance/js/helpers/DocstoreClient.js b/services/docstore/test/acceptance/js/helpers/DocstoreClient.js index 32aadec4b2..0871011a11 100644 --- a/services/docstore/test/acceptance/js/helpers/DocstoreClient.js +++ b/services/docstore/test/acceptance/js/helpers/DocstoreClient.js @@ -33,7 +33,7 @@ module.exports = DocstoreClient = { getDoc(projectId, docId, qs, callback) { request.get( { - url: `http://localhost:${settings.internal.docstore.port}/project/${projectId}/doc/${docId}`, + url: `http://127.0.0.1:${settings.internal.docstore.port}/project/${projectId}/doc/${docId}`, json: true, qs, }, @@ -44,7 +44,7 @@ module.exports = DocstoreClient = { peekDoc(projectId, docId, qs, callback) { request.get( { - url: `http://localhost:${settings.internal.docstore.port}/project/${projectId}/doc/${docId}/peek`, + url: `http://127.0.0.1:${settings.internal.docstore.port}/project/${projectId}/doc/${docId}/peek`, json: true, qs, }, @@ -55,7 +55,7 @@ module.exports = DocstoreClient = { isDocDeleted(projectId, docId, callback) { request.get( { - url: `http://localhost:${settings.internal.docstore.port}/project/${projectId}/doc/${docId}/deleted`, + url: `http://127.0.0.1:${settings.internal.docstore.port}/project/${projectId}/doc/${docId}/deleted`, json: true, }, callback @@ -65,7 +65,7 @@ module.exports = DocstoreClient = { getAllDocs(projectId, callback) { request.get( { - url: `http://localhost:${settings.internal.docstore.port}/project/${projectId}/doc`, + url: `http://127.0.0.1:${settings.internal.docstore.port}/project/${projectId}/doc`, json: true, }, (req, res, body) => { @@ -77,7 +77,7 @@ module.exports = DocstoreClient = { getAllDeletedDocs(projectId, callback) { request.get( { - url: `http://localhost:${settings.internal.docstore.port}/project/${projectId}/doc-deleted`, + url: `http://127.0.0.1:${settings.internal.docstore.port}/project/${projectId}/doc-deleted`, json: true, }, (error, res, body) => { @@ -93,7 +93,7 @@ module.exports = DocstoreClient = { getAllRanges(projectId, callback) { request.get( { - url: `http://localhost:${settings.internal.docstore.port}/project/${projectId}/ranges`, + url: `http://127.0.0.1:${settings.internal.docstore.port}/project/${projectId}/ranges`, json: true, }, callback @@ -103,7 +103,7 @@ module.exports = DocstoreClient = { updateDoc(projectId, docId, lines, version, ranges, callback) { return request.post( { - url: `http://localhost:${settings.internal.docstore.port}/project/${projectId}/doc/${docId}`, + url: `http://127.0.0.1:${settings.internal.docstore.port}/project/${projectId}/doc/${docId}`, json: { lines, version, @@ -147,7 +147,7 @@ module.exports = DocstoreClient = { deleteDocWithDateAndName(projectId, docId, deletedAt, name, callback) { request.patch( { - url: `http://localhost:${settings.internal.docstore.port}/project/${projectId}/doc/${docId}`, + url: `http://127.0.0.1:${settings.internal.docstore.port}/project/${projectId}/doc/${docId}`, json: { name, deleted: true, deletedAt }, }, callback @@ -157,7 +157,7 @@ module.exports = DocstoreClient = { archiveAllDoc(projectId, callback) { request.post( { - url: `http://localhost:${settings.internal.docstore.port}/project/${projectId}/archive`, + url: `http://127.0.0.1:${settings.internal.docstore.port}/project/${projectId}/archive`, }, callback ) @@ -166,7 +166,7 @@ module.exports = DocstoreClient = { archiveDoc(projectId, docId, callback) { request.post( { - url: `http://localhost:${settings.internal.docstore.port}/project/${projectId}/doc/${docId}/archive`, + url: `http://127.0.0.1:${settings.internal.docstore.port}/project/${projectId}/doc/${docId}/archive`, }, callback ) @@ -175,7 +175,7 @@ module.exports = DocstoreClient = { destroyAllDoc(projectId, callback) { request.post( { - url: `http://localhost:${settings.internal.docstore.port}/project/${projectId}/destroy`, + url: `http://127.0.0.1:${settings.internal.docstore.port}/project/${projectId}/destroy`, }, callback ) diff --git a/services/document-updater/app.js b/services/document-updater/app.js index 7a547bd89f..03cc12ec82 100644 --- a/services/document-updater/app.js +++ b/services/document-updater/app.js @@ -245,7 +245,7 @@ const port = Settings.api.documentupdater && Settings.api.documentupdater.port) || 3003 -const host = Settings.internal.documentupdater.host || 'localhost' +const host = Settings.internal.documentupdater.host || '127.0.0.1' if (!module.parent) { // Called directly diff --git a/services/document-updater/config/settings.defaults.js b/services/document-updater/config/settings.defaults.js index ca74768580..f8a3f73f51 100755 --- a/services/document-updater/config/settings.defaults.js +++ b/services/document-updater/config/settings.defaults.js @@ -1,7 +1,7 @@ module.exports = { internal: { documentupdater: { - host: process.env.LISTEN_ADDRESS || 'localhost', + host: process.env.LISTEN_ADDRESS || '127.0.0.1', port: 3003, }, }, @@ -9,20 +9,20 @@ module.exports = { apis: { web: { url: `http://${ - process.env.WEB_API_HOST || process.env.WEB_HOST || 'localhost' + process.env.WEB_API_HOST || process.env.WEB_HOST || '127.0.0.1' }:${process.env.WEB_API_PORT || process.env.WEB_PORT || 3000}`, user: process.env.WEB_API_USER || 'overleaf', pass: process.env.WEB_API_PASSWORD || 'password', }, project_history: { - url: `http://${process.env.PROJECT_HISTORY_HOST || 'localhost'}:3054`, + url: `http://${process.env.PROJECT_HISTORY_HOST || '127.0.0.1'}:3054`, }, }, redis: { pubsub: { host: - process.env.PUBSUB_REDIS_HOST || process.env.REDIS_HOST || 'localhost', + process.env.PUBSUB_REDIS_HOST || process.env.REDIS_HOST || '127.0.0.1', port: process.env.PUBSUB_REDIS_PORT || process.env.REDIS_PORT || '6379', password: process.env.PUBSUB_REDIS_PASSWORD || process.env.REDIS_PASSWORD || '', @@ -34,7 +34,7 @@ module.exports = { history: { port: process.env.HISTORY_REDIS_PORT || process.env.REDIS_PORT || '6379', host: - process.env.HISTORY_REDIS_HOST || process.env.REDIS_HOST || 'localhost', + process.env.HISTORY_REDIS_HOST || process.env.REDIS_HOST || '127.0.0.1', password: process.env.HISTORY_REDIS_PASSWORD || process.env.REDIS_PASSWORD || '', maxRetriesPerRequest: parseInt( @@ -45,7 +45,7 @@ module.exports = { project_history: { port: process.env.HISTORY_REDIS_PORT || process.env.REDIS_PORT || '6379', host: - process.env.HISTORY_REDIS_HOST || process.env.REDIS_HOST || 'localhost', + process.env.HISTORY_REDIS_HOST || process.env.REDIS_HOST || '127.0.0.1', password: process.env.HISTORY_REDIS_PASSWORD || process.env.REDIS_PASSWORD || '', maxRetriesPerRequest: parseInt( @@ -64,7 +64,7 @@ module.exports = { lock: { port: process.env.LOCK_REDIS_PORT || process.env.REDIS_PORT || '6379', host: - process.env.LOCK_REDIS_HOST || process.env.REDIS_HOST || 'localhost', + process.env.LOCK_REDIS_HOST || process.env.REDIS_HOST || '127.0.0.1', password: process.env.LOCK_REDIS_PASSWORD || process.env.REDIS_PASSWORD || '', maxRetriesPerRequest: parseInt( @@ -83,7 +83,7 @@ module.exports = { host: process.env.DOC_UPDATER_REDIS_HOST || process.env.REDIS_HOST || - 'localhost', + '127.0.0.1', password: process.env.DOC_UPDATER_REDIS_PASSWORD || process.env.REDIS_PASSWORD || diff --git a/services/document-updater/test/acceptance/js/helpers/DocUpdaterApp.js b/services/document-updater/test/acceptance/js/helpers/DocUpdaterApp.js index 36517cd834..33c6882138 100644 --- a/services/document-updater/test/acceptance/js/helpers/DocUpdaterApp.js +++ b/services/document-updater/test/acceptance/js/helpers/DocUpdaterApp.js @@ -26,7 +26,7 @@ module.exports = { } this.initing = true this.callbacks.push(callback) - app.listen(3003, 'localhost', error => { + app.listen(3003, '127.0.0.1', error => { if (error != null) { throw error } diff --git a/services/document-updater/test/acceptance/js/helpers/DocUpdaterClient.js b/services/document-updater/test/acceptance/js/helpers/DocUpdaterClient.js index 04cc1feebe..c86bd17e47 100644 --- a/services/document-updater/test/acceptance/js/helpers/DocUpdaterClient.js +++ b/services/document-updater/test/acceptance/js/helpers/DocUpdaterClient.js @@ -97,7 +97,7 @@ module.exports = DocUpdaterClient = { getDoc(projectId, docId, callback) { request.get( - `http://localhost:3003/project/${projectId}/doc/${docId}`, + `http://127.0.0.1:3003/project/${projectId}/doc/${docId}`, (error, res, body) => { if (body != null && res.statusCode >= 200 && res.statusCode < 300) { body = JSON.parse(body) @@ -109,7 +109,7 @@ module.exports = DocUpdaterClient = { getDocAndRecentOps(projectId, docId, fromVersion, callback) { request.get( - `http://localhost:3003/project/${projectId}/doc/${docId}?fromVersion=${fromVersion}`, + `http://127.0.0.1:3003/project/${projectId}/doc/${docId}?fromVersion=${fromVersion}`, (error, res, body) => { if (body != null && res.statusCode >= 200 && res.statusCode < 300) { body = JSON.parse(body) @@ -129,7 +129,7 @@ module.exports = DocUpdaterClient = { peekDoc(projectId, docId, callback) { request.get( - `http://localhost:3003/project/${projectId}/doc/${docId}/peek`, + `http://127.0.0.1:3003/project/${projectId}/doc/${docId}/peek`, (error, res, body) => { if (body != null && res.statusCode >= 200 && res.statusCode < 300) { body = JSON.parse(body) @@ -141,7 +141,7 @@ module.exports = DocUpdaterClient = { flushDoc(projectId, docId, callback) { request.post( - `http://localhost:3003/project/${projectId}/doc/${docId}/flush`, + `http://127.0.0.1:3003/project/${projectId}/doc/${docId}/flush`, (error, res, body) => callback(error, res, body) ) }, @@ -149,7 +149,7 @@ module.exports = DocUpdaterClient = { setDocLines(projectId, docId, lines, source, userId, undoing, callback) { request.post( { - url: `http://localhost:3003/project/${projectId}/doc/${docId}`, + url: `http://127.0.0.1:3003/project/${projectId}/doc/${docId}`, json: { lines, source, @@ -163,36 +163,36 @@ module.exports = DocUpdaterClient = { deleteDoc(projectId, docId, callback) { request.del( - `http://localhost:3003/project/${projectId}/doc/${docId}`, + `http://127.0.0.1:3003/project/${projectId}/doc/${docId}`, (error, res, body) => callback(error, res, body) ) }, flushProject(projectId, callback) { - request.post(`http://localhost:3003/project/${projectId}/flush`, callback) + request.post(`http://127.0.0.1:3003/project/${projectId}/flush`, callback) }, deleteProject(projectId, callback) { - request.del(`http://localhost:3003/project/${projectId}`, callback) + request.del(`http://127.0.0.1:3003/project/${projectId}`, callback) }, deleteProjectOnShutdown(projectId, callback) { request.del( - `http://localhost:3003/project/${projectId}?background=true&shutdown=true`, + `http://127.0.0.1:3003/project/${projectId}?background=true&shutdown=true`, callback ) }, flushOldProjects(callback) { request.get( - 'http://localhost:3003/flush_queued_projects?min_delete_age=1', + 'http://127.0.0.1:3003/flush_queued_projects?min_delete_age=1', callback ) }, acceptChange(projectId, docId, changeId, callback) { request.post( - `http://localhost:3003/project/${projectId}/doc/${docId}/change/${changeId}/accept`, + `http://127.0.0.1:3003/project/${projectId}/doc/${docId}/change/${changeId}/accept`, callback ) }, @@ -200,7 +200,7 @@ module.exports = DocUpdaterClient = { acceptChanges(projectId, docId, changeIds, callback) { request.post( { - url: `http://localhost:3003/project/${projectId}/doc/${docId}/change/accept`, + url: `http://127.0.0.1:3003/project/${projectId}/doc/${docId}/change/accept`, json: { change_ids: changeIds }, }, callback @@ -209,14 +209,14 @@ module.exports = DocUpdaterClient = { removeComment(projectId, docId, comment, callback) { request.del( - `http://localhost:3003/project/${projectId}/doc/${docId}/comment/${comment}`, + `http://127.0.0.1:3003/project/${projectId}/doc/${docId}/comment/${comment}`, callback ) }, getProjectDocs(projectId, projectStateHash, callback) { request.get( - `http://localhost:3003/project/${projectId}/doc?state=${projectStateHash}`, + `http://127.0.0.1:3003/project/${projectId}/doc?state=${projectStateHash}`, (error, res, body) => { if (body != null && res.statusCode >= 200 && res.statusCode < 300) { body = JSON.parse(body) @@ -229,7 +229,7 @@ module.exports = DocUpdaterClient = { sendProjectUpdate(projectId, userId, updates, version, callback) { request.post( { - url: `http://localhost:3003/project/${projectId}`, + url: `http://127.0.0.1:3003/project/${projectId}`, json: { userId, updates, version }, }, (error, res, body) => callback(error, res, body) diff --git a/services/document-updater/test/cluster_failover/js/test_blpop_failover.js b/services/document-updater/test/cluster_failover/js/test_blpop_failover.js index b6a83e3b34..17d9a2685d 100644 --- a/services/document-updater/test/cluster_failover/js/test_blpop_failover.js +++ b/services/document-updater/test/cluster_failover/js/test_blpop_failover.js @@ -4,7 +4,7 @@ const rclient1 = redis.createClient({ cluster: [ { port: '7000', - host: 'localhost', + host: '127.0.0.1', }, ], }) @@ -13,7 +13,7 @@ const rclient2 = redis.createClient({ cluster: [ { port: '7000', - host: 'localhost', + host: '127.0.0.1', }, ], }) diff --git a/services/document-updater/test/cluster_failover/js/test_pubsub_failover.js b/services/document-updater/test/cluster_failover/js/test_pubsub_failover.js index 44ad70c6ec..ebc04a34f9 100644 --- a/services/document-updater/test/cluster_failover/js/test_pubsub_failover.js +++ b/services/document-updater/test/cluster_failover/js/test_pubsub_failover.js @@ -4,7 +4,7 @@ const rclient1 = redis.createClient({ cluster: [ { port: '7000', - host: 'localhost', + host: '127.0.0.1', }, ], }) @@ -13,7 +13,7 @@ const rclient2 = redis.createClient({ cluster: [ { port: '7000', - host: 'localhost', + host: '127.0.0.1', }, ], }) diff --git a/services/filestore/config/settings.defaults.js b/services/filestore/config/settings.defaults.js index 47eb94c4fb..35c5b678b6 100644 --- a/services/filestore/config/settings.defaults.js +++ b/services/filestore/config/settings.defaults.js @@ -37,7 +37,7 @@ const settings = { internal: { filestore: { port: 3009, - host: process.env.LISTEN_ADDRESS || 'localhost', + host: process.env.LISTEN_ADDRESS || '127.0.0.1', }, }, diff --git a/services/filestore/test/acceptance/deps/Dockerfile.fake-gcs b/services/filestore/test/acceptance/deps/Dockerfile.fake-gcs index 2dac8cdb2c..d39a293915 100644 --- a/services/filestore/test/acceptance/deps/Dockerfile.fake-gcs +++ b/services/filestore/test/acceptance/deps/Dockerfile.fake-gcs @@ -1,5 +1,5 @@ FROM fsouza/fake-gcs-server:1.20 RUN apk add --update --no-cache curl COPY healthcheck.sh /healthcheck.sh -HEALTHCHECK --interval=1s --timeout=1s --retries=30 CMD /healthcheck.sh http://localhost:9090 +HEALTHCHECK --interval=1s --timeout=1s --retries=30 CMD /healthcheck.sh http://127.0.0.1:9090 CMD ["--port=9090", "--scheme=http"] diff --git a/services/filestore/test/acceptance/deps/Dockerfile.s3mock b/services/filestore/test/acceptance/deps/Dockerfile.s3mock index 6509092bd8..8b033fa3a3 100644 --- a/services/filestore/test/acceptance/deps/Dockerfile.s3mock +++ b/services/filestore/test/acceptance/deps/Dockerfile.s3mock @@ -1,4 +1,4 @@ FROM adobe/s3mock:2.4.14 RUN apk add --update --no-cache curl COPY healthcheck.sh /healthcheck.sh -HEALTHCHECK --interval=1s --timeout=1s --retries=30 CMD /healthcheck.sh http://localhost:9090 +HEALTHCHECK --interval=1s --timeout=1s --retries=30 CMD /healthcheck.sh http://127.0.0.1:9090 diff --git a/services/filestore/test/acceptance/js/FilestoreApp.js b/services/filestore/test/acceptance/js/FilestoreApp.js index 25c758e5cc..9ed329d8df 100644 --- a/services/filestore/test/acceptance/js/FilestoreApp.js +++ b/services/filestore/test/acceptance/js/FilestoreApp.js @@ -32,7 +32,7 @@ class FilestoreApp { await new Promise((resolve, reject) => { this.server = this.app.listen( Settings.internal.filestore.port, - 'localhost', + '127.0.0.1', err => { if (err) { return reject(err) diff --git a/services/filestore/test/acceptance/js/FilestoreTests.js b/services/filestore/test/acceptance/js/FilestoreTests.js index b33eb747be..ad1acdc7ea 100644 --- a/services/filestore/test/acceptance/js/FilestoreTests.js +++ b/services/filestore/test/acceptance/js/FilestoreTests.js @@ -36,7 +36,7 @@ const BackendSettings = require('./TestConfig') describe('Filestore', function () { this.timeout(1000 * 10) - const filestoreUrl = `http://localhost:${Settings.internal.filestore.port}` + const filestoreUrl = `http://127.0.0.1:${Settings.internal.filestore.port}` const seenSockets = [] async function expectNoSockets() { diff --git a/services/history-v1/test/acceptance/js/api/support/test_server.js b/services/history-v1/test/acceptance/js/api/support/test_server.js index a0753b908f..470a60a4ce 100644 --- a/services/history-v1/test/acceptance/js/api/support/test_server.js +++ b/services/history-v1/test/acceptance/js/api/support/test_server.js @@ -16,7 +16,7 @@ const Swagger = require('swagger-client') const app = require('../../../../../app') function testUrl(pathname, opts = {}) { - const url = new URL('http://localhost') + const url = new URL('http://127.0.0.1') url.port = exports.server.address().port url.pathname = pathname if (opts.qs) { diff --git a/services/notifications/app.js b/services/notifications/app.js index ea210540ac..38292c7c13 100644 --- a/services/notifications/app.js +++ b/services/notifications/app.js @@ -49,7 +49,7 @@ app.get('/health_check', (req, res) => app.get('*', (req, res) => res.sendStatus(404)) -const host = Settings.internal?.notifications?.host || 'localhost' +const host = Settings.internal?.notifications?.host || '127.0.0.1' const port = Settings.internal?.notifications?.port || 3042 mongoClient diff --git a/services/notifications/app/js/HealthCheckController.js b/services/notifications/app/js/HealthCheckController.js index 12601fe49f..b08be32cf8 100644 --- a/services/notifications/app/js/HealthCheckController.js +++ b/services/notifications/app/js/HealthCheckController.js @@ -24,7 +24,7 @@ module.exports = { let notificationKey = `smoke-test-notification-${new ObjectId()}` const getOpts = endPath => ({ - url: `http://localhost:${port}/user/${userId}${endPath}`, + url: `http://127.0.0.1:${port}/user/${userId}${endPath}`, timeout: 5000, }) logger.debug( diff --git a/services/notifications/config/settings.defaults.js b/services/notifications/config/settings.defaults.js index d70ad6ac64..3453b88bd6 100644 --- a/services/notifications/config/settings.defaults.js +++ b/services/notifications/config/settings.defaults.js @@ -2,14 +2,14 @@ module.exports = { internal: { notifications: { port: 3042, - host: process.env.LISTEN_ADDRESS || 'localhost', + host: process.env.LISTEN_ADDRESS || '127.0.0.1', }, }, mongo: { url: process.env.MONGO_CONNECTION_STRING || - `mongodb://${process.env.MONGO_HOST || 'localhost'}/sharelatex`, + `mongodb://${process.env.MONGO_HOST || '127.0.0.1'}/sharelatex`, options: { monitorCommands: true, }, diff --git a/services/project-history/app/js/HealthChecker.js b/services/project-history/app/js/HealthChecker.js index c9094eec7f..74f1272e1e 100644 --- a/services/project-history/app/js/HealthChecker.js +++ b/services/project-history/app/js/HealthChecker.js @@ -18,12 +18,12 @@ const { port } = settings.internal.history export function check(callback) { const projectId = new ObjectId(settings.history.healthCheck.project_id) - const url = `http://localhost:${port}/project/${projectId}` + const url = `http://127.0.0.1:${port}/project/${projectId}` logger.debug({ projectId }, 'running health check') const jobs = [ cb => request.get( - { url: `http://localhost:${port}/check_lock`, timeout: 3000 }, + { url: `http://127.0.0.1:${port}/check_lock`, timeout: 3000 }, function (err, res, body) { if (err != null) { OError.tag(err, 'error checking lock for health check', { diff --git a/services/project-history/config/settings.defaults.cjs b/services/project-history/config/settings.defaults.cjs index 4aafd85a5c..dd8855a806 100644 --- a/services/project-history/config/settings.defaults.cjs +++ b/services/project-history/config/settings.defaults.cjs @@ -2,7 +2,7 @@ module.exports = { mongo: { url: process.env.MONGO_CONNECTION_STRING || - `mongodb://${process.env.MONGO_HOST || 'localhost'}/sharelatex`, + `mongodb://${process.env.MONGO_HOST || '127.0.0.1'}/sharelatex`, options: { monitorCommands: true, }, @@ -10,25 +10,25 @@ module.exports = { internal: { history: { port: 3054, - host: process.env.LISTEN_ADDRESS || 'localhost', + host: process.env.LISTEN_ADDRESS || '127.0.0.1', }, }, apis: { documentupdater: { - url: `http://${process.env.DOCUPDATER_HOST || 'localhost'}:3003`, + url: `http://${process.env.DOCUPDATER_HOST || '127.0.0.1'}:3003`, }, docstore: { - url: `http://${process.env.DOCSTORE_HOST || 'localhost'}:3016`, + url: `http://${process.env.DOCSTORE_HOST || '127.0.0.1'}:3016`, }, filestore: { - url: `http://${process.env.FILESTORE_HOST || 'localhost'}:3009`, + url: `http://${process.env.FILESTORE_HOST || '127.0.0.1'}:3009`, }, history_v1: { requestTimeout: parseInt(process.env.V1_REQUEST_TIMEOUT || '300000', 10), }, web: { url: `http://${ - process.env.WEB_API_HOST || process.env.WEB_HOST || 'localhost' + process.env.WEB_API_HOST || process.env.WEB_HOST || '127.0.0.1' }:${process.env.WEB_PORT || 3000}`, user: process.env.WEB_API_USER || 'overleaf', pass: process.env.WEB_API_PASSWORD || 'password', @@ -40,7 +40,7 @@ module.exports = { }, redis: { lock: { - host: process.env.REDIS_HOST || 'localhost', + host: process.env.REDIS_HOST || '127.0.0.1', password: process.env.REDIS_PASSWORD, port: process.env.REDIS_PORT || 6379, key_schema: { @@ -51,7 +51,7 @@ module.exports = { }, project_history: { host: - process.env.HISTORY_REDIS_HOST || process.env.REDIS_HOST || 'localhost', + process.env.HISTORY_REDIS_HOST || process.env.REDIS_HOST || '127.0.0.1', port: process.env.HISTORY_REDIS_PORT || process.env.REDIS_PORT || 6379, password: process.env.HISTORY_REDIS_PASSWORD || process.env.REDIS_PASSWORD, @@ -82,7 +82,7 @@ module.exports = { `http://${ process.env.V1_HISTORY_HOST || process.env.HISTORY_V1_HOST || - 'localhost' + '127.0.0.1' }:3100/api`, user: process.env.V1_HISTORY_USER || 'staging', pass: process.env.V1_HISTORY_PASSWORD || 'password', diff --git a/services/project-history/test/acceptance/js/DeleteProjectTests.js b/services/project-history/test/acceptance/js/DeleteProjectTests.js index afc9ebd42f..dcda54a57f 100644 --- a/services/project-history/test/acceptance/js/DeleteProjectTests.js +++ b/services/project-history/test/acceptance/js/DeleteProjectTests.js @@ -5,8 +5,8 @@ import * as ProjectHistoryApp from './helpers/ProjectHistoryApp.js' import * as ProjectHistoryClient from './helpers/ProjectHistoryClient.js' const { ObjectId } = mongodb -const MockHistoryStore = () => nock('http://localhost:3100') -const MockWeb = () => nock('http://localhost:3000') +const MockHistoryStore = () => nock('http://127.0.0.1:3100') +const MockWeb = () => nock('http://127.0.0.1:3000') const fixture = path => new URL(`../fixtures/${path}`, import.meta.url) describe('Deleting project', function () { diff --git a/services/project-history/test/acceptance/js/DiffTests.js b/services/project-history/test/acceptance/js/DiffTests.js index 60607c48ff..095063cca7 100644 --- a/services/project-history/test/acceptance/js/DiffTests.js +++ b/services/project-history/test/acceptance/js/DiffTests.js @@ -7,8 +7,8 @@ import * as ProjectHistoryClient from './helpers/ProjectHistoryClient.js' import * as ProjectHistoryApp from './helpers/ProjectHistoryApp.js' const { ObjectId } = mongodb -const MockHistoryStore = () => nock('http://localhost:3100') -const MockWeb = () => nock('http://localhost:3000') +const MockHistoryStore = () => nock('http://127.0.0.1:3100') +const MockWeb = () => nock('http://127.0.0.1:3000') function createMockBlob(historyId, content) { const sha = crypto.createHash('sha1').update(content).digest('hex') @@ -316,7 +316,7 @@ describe('Diffs', function () { request.get( { - url: `http://localhost:3054/project/${this.projectId}/diff`, + url: `http://127.0.0.1:3054/project/${this.projectId}/diff`, qs: { pathname: 'not_here.tex', from: 3, diff --git a/services/project-history/test/acceptance/js/DiscardingUpdatesTests.js b/services/project-history/test/acceptance/js/DiscardingUpdatesTests.js index 35b433a89b..1fd6f1e874 100644 --- a/services/project-history/test/acceptance/js/DiscardingUpdatesTests.js +++ b/services/project-history/test/acceptance/js/DiscardingUpdatesTests.js @@ -21,8 +21,8 @@ import * as ProjectHistoryClient from './helpers/ProjectHistoryClient.js' import * as ProjectHistoryApp from './helpers/ProjectHistoryApp.js' const { ObjectId } = mongodb -const MockHistoryStore = () => nock('http://localhost:3100') -const MockWeb = () => nock('http://localhost:3000') +const MockHistoryStore = () => nock('http://127.0.0.1:3100') +const MockWeb = () => nock('http://127.0.0.1:3000') describe('DiscardingUpdates', function () { beforeEach(function (done) { diff --git a/services/project-history/test/acceptance/js/FileTreeDiffTests.js b/services/project-history/test/acceptance/js/FileTreeDiffTests.js index 6263c117fb..ae29ff9354 100644 --- a/services/project-history/test/acceptance/js/FileTreeDiffTests.js +++ b/services/project-history/test/acceptance/js/FileTreeDiffTests.js @@ -24,9 +24,9 @@ import * as ProjectHistoryApp from './helpers/ProjectHistoryApp.js' import * as HistoryId from './helpers/HistoryId.js' const { ObjectId } = mongodb -const MockHistoryStore = () => nock('http://localhost:3100') -const MockFileStore = () => nock('http://localhost:3009') -const MockWeb = () => nock('http://localhost:3000') +const MockHistoryStore = () => nock('http://127.0.0.1:3100') +const MockFileStore = () => nock('http://127.0.0.1:3009') +const MockWeb = () => nock('http://127.0.0.1:3000') const sha = data => crypto.createHash('sha1').update(data).digest('hex') diff --git a/services/project-history/test/acceptance/js/FlushManagerTests.js b/services/project-history/test/acceptance/js/FlushManagerTests.js index 9879254b50..01082f2fbd 100644 --- a/services/project-history/test/acceptance/js/FlushManagerTests.js +++ b/services/project-history/test/acceptance/js/FlushManagerTests.js @@ -8,8 +8,8 @@ import * as ProjectHistoryClient from './helpers/ProjectHistoryClient.js' import * as ProjectHistoryApp from './helpers/ProjectHistoryApp.js' const { ObjectId } = mongodb -const MockHistoryStore = () => nock('http://localhost:3100') -const MockWeb = () => nock('http://localhost:3000') +const MockHistoryStore = () => nock('http://127.0.0.1:3100') +const MockWeb = () => nock('http://127.0.0.1:3000') describe('Flushing old queues', function () { const historyId = new ObjectId().toString() @@ -90,7 +90,7 @@ describe('Flushing old queues', function () { it('flushes the project history queue', function (done) { request.post( { - url: 'http://localhost:3054/flush/old?maxAge=10800', + url: 'http://127.0.0.1:3054/flush/old?maxAge=10800', }, (error, res, body) => { if (error) { @@ -109,7 +109,7 @@ describe('Flushing old queues', function () { it('flushes the project history queue in the background when requested', function (done) { request.post( { - url: 'http://localhost:3054/flush/old?maxAge=10800&background=1', + url: 'http://127.0.0.1:3054/flush/old?maxAge=10800&background=1', }, (error, res, body) => { if (error) { @@ -166,7 +166,7 @@ describe('Flushing old queues', function () { it('does not flush the project history queue', function (done) { request.post( { - url: `http://localhost:3054/flush/old?maxAge=${3 * 3600}`, + url: `http://127.0.0.1:3054/flush/old?maxAge=${3 * 3600}`, }, (error, res, body) => { if (error) { @@ -213,7 +213,7 @@ describe('Flushing old queues', function () { it('flushes the project history queue anyway', function (done) { request.post( { - url: `http://localhost:3054/flush/old?maxAge=${3 * 3600}`, + url: `http://127.0.0.1:3054/flush/old?maxAge=${3 * 3600}`, }, (error, res, body) => { if (error) { diff --git a/services/project-history/test/acceptance/js/HealthCheckTests.js b/services/project-history/test/acceptance/js/HealthCheckTests.js index c67c2f0df1..1fc9efa14c 100644 --- a/services/project-history/test/acceptance/js/HealthCheckTests.js +++ b/services/project-history/test/acceptance/js/HealthCheckTests.js @@ -18,8 +18,8 @@ import * as ProjectHistoryClient from './helpers/ProjectHistoryClient.js' import * as ProjectHistoryApp from './helpers/ProjectHistoryApp.js' const { ObjectId } = mongodb -const MockHistoryStore = () => nock('http://localhost:3100') -const MockWeb = () => nock('http://localhost:3000') +const MockHistoryStore = () => nock('http://127.0.0.1:3100') +const MockWeb = () => nock('http://127.0.0.1:3000') describe('Health Check', function () { beforeEach(function (done) { @@ -62,7 +62,7 @@ describe('Health Check', function () { return it('should respond to the health check', function (done) { return request.get( { - url: 'http://localhost:3054/health_check', + url: 'http://127.0.0.1:3054/health_check', }, (error, res, body) => { if (error != null) { diff --git a/services/project-history/test/acceptance/js/LabelsTests.js b/services/project-history/test/acceptance/js/LabelsTests.js index a31e5c670f..e872cf7d48 100644 --- a/services/project-history/test/acceptance/js/LabelsTests.js +++ b/services/project-history/test/acceptance/js/LabelsTests.js @@ -19,9 +19,9 @@ import * as ProjectHistoryClient from './helpers/ProjectHistoryClient.js' import * as ProjectHistoryApp from './helpers/ProjectHistoryApp.js' const { ObjectId } = mongodb -const MockHistoryStore = () => nock('http://localhost:3100') -const MockFileStore = () => nock('http://localhost:3009') -const MockWeb = () => nock('http://localhost:3000') +const MockHistoryStore = () => nock('http://127.0.0.1:3100') +const MockFileStore = () => nock('http://127.0.0.1:3009') +const MockWeb = () => nock('http://127.0.0.1:3000') const fixture = path => new URL(`../fixtures/${path}`, import.meta.url) diff --git a/services/project-history/test/acceptance/js/ReadingASnapshotTests.js b/services/project-history/test/acceptance/js/ReadingASnapshotTests.js index 210aa6693b..af373bf773 100644 --- a/services/project-history/test/acceptance/js/ReadingASnapshotTests.js +++ b/services/project-history/test/acceptance/js/ReadingASnapshotTests.js @@ -5,8 +5,8 @@ import * as ProjectHistoryClient from './helpers/ProjectHistoryClient.js' import * as ProjectHistoryApp from './helpers/ProjectHistoryApp.js' const { ObjectId } = mongodb -const MockHistoryStore = () => nock('http://localhost:3100') -const MockWeb = () => nock('http://localhost:3000') +const MockHistoryStore = () => nock('http://127.0.0.1:3100') +const MockWeb = () => nock('http://127.0.0.1:3000') const fixture = path => new URL(`../fixtures/${path}`, import.meta.url) diff --git a/services/project-history/test/acceptance/js/RetryTests.js b/services/project-history/test/acceptance/js/RetryTests.js index 1bcfcdd5f5..aea3a68324 100644 --- a/services/project-history/test/acceptance/js/RetryTests.js +++ b/services/project-history/test/acceptance/js/RetryTests.js @@ -8,10 +8,10 @@ import * as ProjectHistoryClient from './helpers/ProjectHistoryClient.js' import * as ProjectHistoryApp from './helpers/ProjectHistoryApp.js' const { ObjectId } = mongodb -const MockHistoryStore = () => nock('http://localhost:3100') -const MockWeb = () => nock('http://localhost:3000') +const MockHistoryStore = () => nock('http://127.0.0.1:3100') +const MockWeb = () => nock('http://127.0.0.1:3000') -const MockCallback = () => nock('http://localhost') +const MockCallback = () => nock('http://127.0.0.1') describe('Retrying failed projects', function () { const historyId = new ObjectId().toString() @@ -95,7 +95,7 @@ describe('Retrying failed projects', function () { it('flushes the project history queue', function (done) { request.post( { - url: 'http://localhost:3054/retry/failures?failureType=soft&limit=1&timeout=10000', + url: 'http://127.0.0.1:3054/retry/failures?failureType=soft&limit=1&timeout=10000', }, (error, res, body) => { if (error) { @@ -118,7 +118,7 @@ describe('Retrying failed projects', function () { .reply(200) request.post( { - url: 'http://localhost:3054/retry/failures?failureType=soft&limit=1&timeout=10000&callbackUrl=http%3A%2F%2Flocalhost%2Fping', + url: 'http://127.0.0.1:3054/retry/failures?failureType=soft&limit=1&timeout=10000&callbackUrl=http%3A%2F%2F127.0.0.1%2Fping', headers: { 'X-CALLBACK-Authorization': '123', }, @@ -177,7 +177,7 @@ describe('Retrying failed projects', function () { request.post( { - url: 'http://localhost:3054/retry/failures?failureType=hard&limit=1&timeout=10000', + url: 'http://127.0.0.1:3054/retry/failures?failureType=hard&limit=1&timeout=10000', }, (error, res, body) => { if (error) { diff --git a/services/project-history/test/acceptance/js/SendingUpdatesTests.js b/services/project-history/test/acceptance/js/SendingUpdatesTests.js index ce1adf4958..6d25eff6af 100644 --- a/services/project-history/test/acceptance/js/SendingUpdatesTests.js +++ b/services/project-history/test/acceptance/js/SendingUpdatesTests.js @@ -9,9 +9,9 @@ import * as ProjectHistoryClient from './helpers/ProjectHistoryClient.js' import * as ProjectHistoryApp from './helpers/ProjectHistoryApp.js' const { ObjectId } = mongodb -const MockHistoryStore = () => nock('http://localhost:3100') -const MockFileStore = () => nock('http://localhost:3009') -const MockWeb = () => nock('http://localhost:3000') +const MockHistoryStore = () => nock('http://127.0.0.1:3100') +const MockFileStore = () => nock('http://127.0.0.1:3009') +const MockWeb = () => nock('http://127.0.0.1:3000') // Some helper methods to make the tests more compact function slTextUpdate(historyId, doc, userId, v, ts, op) { @@ -57,7 +57,7 @@ function slAddFileUpdate(historyId, file, userId, ts, projectId) { return { projectHistoryId: historyId, pathname: file.pathname, - url: `http://localhost:3009/project/${projectId}/file/${file.id}`, + url: `http://127.0.0.1:3009/project/${projectId}/file/${file.id}`, file: file.id, meta: { user_id: userId, ts: ts.getTime() }, } diff --git a/services/project-history/test/acceptance/js/SummarisedUpdatesTests.js b/services/project-history/test/acceptance/js/SummarisedUpdatesTests.js index f3c433a9ba..f1abf9f24e 100644 --- a/services/project-history/test/acceptance/js/SummarisedUpdatesTests.js +++ b/services/project-history/test/acceptance/js/SummarisedUpdatesTests.js @@ -21,9 +21,9 @@ import * as ProjectHistoryClient from './helpers/ProjectHistoryClient.js' import * as ProjectHistoryApp from './helpers/ProjectHistoryApp.js' const { ObjectId } = mongodb -const MockHistoryStore = () => nock('http://localhost:3100') -const MockFileStore = () => nock('http://localhost:3009') -const MockWeb = () => nock('http://localhost:3000') +const MockHistoryStore = () => nock('http://127.0.0.1:3100') +const MockFileStore = () => nock('http://127.0.0.1:3009') +const MockWeb = () => nock('http://127.0.0.1:3000') const fixture = path => new URL(`../fixtures/${path}`, import.meta.url) diff --git a/services/project-history/test/acceptance/js/SyncTests.js b/services/project-history/test/acceptance/js/SyncTests.js index 7412df955c..df25407a35 100644 --- a/services/project-history/test/acceptance/js/SyncTests.js +++ b/services/project-history/test/acceptance/js/SyncTests.js @@ -10,9 +10,9 @@ const { ObjectId } = mongodb const EMPTY_FILE_HASH = 'e69de29bb2d1d6434b8b29ae775ad8c2e48c5391' -const MockHistoryStore = () => nock('http://localhost:3100') -const MockFileStore = () => nock('http://localhost:3009') -const MockWeb = () => nock('http://localhost:3000') +const MockHistoryStore = () => nock('http://127.0.0.1:3100') +const MockFileStore = () => nock('http://127.0.0.1:3009') +const MockWeb = () => nock('http://127.0.0.1:3000') describe('Syncing with web and doc-updater', function () { const historyId = new ObjectId().toString() @@ -68,7 +68,7 @@ describe('Syncing with web and doc-updater', function () { it('404s if project-history is not enabled', function (done) { request.post( { - url: `http://localhost:3054/project/${this.project_id}/resync`, + url: `http://127.0.0.1:3054/project/${this.project_id}/resync`, }, (error, res, body) => { if (error) { @@ -244,7 +244,7 @@ describe('Syncing with web and doc-updater', function () { { file: this.file_id, path: '/test.png', - url: `http://localhost:3009/project/${this.project_id}/file/${this.file_id}`, + url: `http://127.0.0.1:3009/project/${this.project_id}/file/${this.file_id}`, }, { path: '/persistedFile' }, ], diff --git a/services/project-history/test/acceptance/js/helpers/ProjectHistoryApp.js b/services/project-history/test/acceptance/js/helpers/ProjectHistoryApp.js index 6198e0d336..4fb9993c63 100644 --- a/services/project-history/test/acceptance/js/helpers/ProjectHistoryApp.js +++ b/services/project-history/test/acceptance/js/helpers/ProjectHistoryApp.js @@ -27,7 +27,7 @@ export function ensureRunning(callback) { } initing = true callbacks.push(callback) - app.listen(3054, 'localhost', error => { + app.listen(3054, '127.0.0.1', error => { if (error != null) { throw error } diff --git a/services/project-history/test/acceptance/js/helpers/ProjectHistoryClient.js b/services/project-history/test/acceptance/js/helpers/ProjectHistoryClient.js index e1cc96f45b..65f7ceb10b 100644 --- a/services/project-history/test/acceptance/js/helpers/ProjectHistoryClient.js +++ b/services/project-history/test/acceptance/js/helpers/ProjectHistoryClient.js @@ -14,7 +14,7 @@ export function resetDatabase(callback) { export function initializeProject(historyId, callback) { request.post( { - url: 'http://localhost:3054/project', + url: 'http://127.0.0.1:3054/project', json: { historyId }, }, (error, res, body) => { @@ -37,7 +37,7 @@ export function flushProject(projectId, options, callback) { } request.post( { - url: `http://localhost:3054/project/${projectId}/flush`, + url: `http://127.0.0.1:3054/project/${projectId}/flush`, }, (error, res, body) => { if (error) { @@ -54,7 +54,7 @@ export function flushProject(projectId, options, callback) { export function getSummarizedUpdates(projectId, query, callback) { request.get( { - url: `http://localhost:3054/project/${projectId}/updates`, + url: `http://127.0.0.1:3054/project/${projectId}/updates`, qs: query, json: true, }, @@ -71,7 +71,7 @@ export function getSummarizedUpdates(projectId, query, callback) { export function getDiff(projectId, pathname, from, to, callback) { request.get( { - url: `http://localhost:3054/project/${projectId}/diff`, + url: `http://127.0.0.1:3054/project/${projectId}/diff`, qs: { pathname, from, @@ -92,7 +92,7 @@ export function getDiff(projectId, pathname, from, to, callback) { export function getFileTreeDiff(projectId, from, to, callback) { request.get( { - url: `http://localhost:3054/project/${projectId}/filetree/diff`, + url: `http://127.0.0.1:3054/project/${projectId}/filetree/diff`, qs: { from, to, @@ -118,7 +118,7 @@ export function getSnapshot(projectId, pathname, version, options, callback) { } request.get( { - url: `http://localhost:3054/project/${projectId}/version/${version}/${encodeURIComponent( + url: `http://127.0.0.1:3054/project/${projectId}/version/${version}/${encodeURIComponent( pathname )}`, }, @@ -171,7 +171,7 @@ export function getQueueLength(projectId, callback) { export function getQueueCounts(callback) { return request.get( { - url: 'http://localhost:3054/status/queue', + url: 'http://127.0.0.1:3054/status/queue', json: true, }, callback @@ -181,7 +181,7 @@ export function getQueueCounts(callback) { export function resyncHistory(projectId, callback) { request.post( { - url: `http://localhost:3054/project/${projectId}/resync`, + url: `http://127.0.0.1:3054/project/${projectId}/resync`, json: true, body: { origin: { kind: 'test-origin' } }, }, @@ -205,7 +205,7 @@ export function createLabel( ) { request.post( { - url: `http://localhost:3054/project/${projectId}/user/${userId}/labels`, + url: `http://127.0.0.1:3054/project/${projectId}/user/${userId}/labels`, json: { comment, version, created_at: createdAt }, }, (error, res, body) => { @@ -221,7 +221,7 @@ export function createLabel( export function getLabels(projectId, callback) { request.get( { - url: `http://localhost:3054/project/${projectId}/labels`, + url: `http://127.0.0.1:3054/project/${projectId}/labels`, json: true, }, (error, res, body) => { @@ -237,7 +237,7 @@ export function getLabels(projectId, callback) { export function deleteLabelForUser(projectId, userId, labelId, callback) { request.delete( { - url: `http://localhost:3054/project/${projectId}/user/${userId}/labels/${labelId}`, + url: `http://127.0.0.1:3054/project/${projectId}/user/${userId}/labels/${labelId}`, }, (error, res, body) => { if (error) { @@ -252,7 +252,7 @@ export function deleteLabelForUser(projectId, userId, labelId, callback) { export function deleteLabel(projectId, labelId, callback) { request.delete( { - url: `http://localhost:3054/project/${projectId}/labels/${labelId}`, + url: `http://127.0.0.1:3054/project/${projectId}/labels/${labelId}`, }, (error, res, body) => { if (error) { @@ -279,7 +279,7 @@ export function setFailure(failureEntry, callback) { export function transferLabelOwnership(fromUser, toUser, callback) { request.post( { - url: `http://localhost:3054/user/${fromUser}/labels/transfer/${toUser}`, + url: `http://127.0.0.1:3054/user/${fromUser}/labels/transfer/${toUser}`, }, (error, res, body) => { if (error) { @@ -293,7 +293,7 @@ export function transferLabelOwnership(fromUser, toUser, callback) { export function getDump(projectId, callback) { request.get( - `http://localhost:3054/project/${projectId}/dump`, + `http://127.0.0.1:3054/project/${projectId}/dump`, (err, res, body) => { if (err) { return callback(err) @@ -305,7 +305,7 @@ export function getDump(projectId, callback) { } export function deleteProject(projectId, callback) { - request.delete(`http://localhost:3054/project/${projectId}`, (err, res) => { + request.delete(`http://127.0.0.1:3054/project/${projectId}`, (err, res) => { if (err) { return callback(err) } diff --git a/services/real-time/config/settings.defaults.js b/services/real-time/config/settings.defaults.js index 4defc888cb..2065bc7799 100644 --- a/services/real-time/config/settings.defaults.js +++ b/services/real-time/config/settings.defaults.js @@ -4,7 +4,7 @@ const settings = { redis: { pubsub: { host: - process.env.PUBSUB_REDIS_HOST || process.env.REDIS_HOST || 'localhost', + process.env.PUBSUB_REDIS_HOST || process.env.REDIS_HOST || '127.0.0.1', port: process.env.PUBSUB_REDIS_PORT || process.env.REDIS_PORT || '6379', password: process.env.PUBSUB_REDIS_PASSWORD || process.env.REDIS_PASSWORD || '', @@ -19,7 +19,7 @@ const settings = { host: process.env.REAL_TIME_REDIS_HOST || process.env.REDIS_HOST || - 'localhost', + '127.0.0.1', port: process.env.REAL_TIME_REDIS_PORT || process.env.REDIS_PORT || '6379', password: @@ -45,7 +45,7 @@ const settings = { host: process.env.DOC_UPDATER_REDIS_HOST || process.env.REDIS_HOST || - 'localhost', + '127.0.0.1', port: process.env.DOC_UPDATER_REDIS_PORT || process.env.REDIS_PORT || '6379', password: @@ -68,7 +68,7 @@ const settings = { host: process.env.SESSIONS_REDIS_HOST || process.env.REDIS_HOST || - 'localhost', + '127.0.0.1', port: process.env.SESSIONS_REDIS_PORT || process.env.REDIS_PORT || '6379', password: process.env.SESSIONS_REDIS_PASSWORD || process.env.REDIS_PASSWORD || '', @@ -83,14 +83,14 @@ const settings = { internal: { realTime: { port: 3026, - host: process.env.LISTEN_ADDRESS || 'localhost', + host: process.env.LISTEN_ADDRESS || '127.0.0.1', }, }, apis: { web: { url: `http://${ - process.env.WEB_API_HOST || process.env.WEB_HOST || 'localhost' + process.env.WEB_API_HOST || process.env.WEB_HOST || '127.0.0.1' }:${process.env.WEB_API_PORT || process.env.WEB_PORT || 3000}`, user: process.env.WEB_API_USER || 'overleaf', pass: process.env.WEB_API_PASSWORD || 'password', @@ -99,7 +99,7 @@ const settings = { url: `http://${ process.env.DOCUMENT_UPDATER_HOST || process.env.DOCUPDATER_HOST || - 'localhost' + '127.0.0.1' }:3003`, }, }, diff --git a/services/real-time/test/acceptance/js/DrainManagerTests.js b/services/real-time/test/acceptance/js/DrainManagerTests.js index 1b8011c168..99502e2246 100644 --- a/services/real-time/test/acceptance/js/DrainManagerTests.js +++ b/services/real-time/test/acceptance/js/DrainManagerTests.js @@ -16,7 +16,7 @@ const request = require('request') const drain = function (rate, callback) { request.post( { - url: `http://localhost:3026/drain?rate=${rate}`, + url: `http://127.0.0.1:3026/drain?rate=${rate}`, }, (error, response, data) => callback(error, data) ) diff --git a/services/real-time/test/acceptance/js/HttpControllerTests.js b/services/real-time/test/acceptance/js/HttpControllerTests.js index 65ccaff970..ce84b1a280 100644 --- a/services/real-time/test/acceptance/js/HttpControllerTests.js +++ b/services/real-time/test/acceptance/js/HttpControllerTests.js @@ -8,7 +8,7 @@ const async = require('async') const { expect } = require('chai') const request = require('request').defaults({ - baseUrl: 'http://localhost:3026', + baseUrl: 'http://127.0.0.1:3026', }) const RealTimeClient = require('./helpers/RealTimeClient') diff --git a/services/real-time/test/acceptance/js/helpers/RealTimeClient.js b/services/real-time/test/acceptance/js/helpers/RealTimeClient.js index a73028bbf8..c278787414 100644 --- a/services/real-time/test/acceptance/js/helpers/RealTimeClient.js +++ b/services/real-time/test/acceptance/js/helpers/RealTimeClient.js @@ -74,7 +74,7 @@ module.exports = Client = { }, connect(projectId, callback) { - const client = io.connect('http://localhost:3026', { + const client = io.connect('http://127.0.0.1:3026', { 'force new connection': true, query: new URLSearchParams({ projectId }).toString(), }) @@ -105,7 +105,7 @@ module.exports = Client = { } return request.get( { - url: 'http://localhost:3026/clients', + url: 'http://127.0.0.1:3026/clients', json: true, }, (error, response, data) => callback(error, data) @@ -118,7 +118,7 @@ module.exports = Client = { } return request.get( { - url: `http://localhost:3026/clients/${clientId}`, + url: `http://127.0.0.1:3026/clients/${clientId}`, json: true, }, (error, response, data) => { @@ -134,7 +134,7 @@ module.exports = Client = { disconnectClient(clientId, callback) { request.post( { - url: `http://localhost:3026/client/${clientId}/disconnect`, + url: `http://127.0.0.1:3026/client/${clientId}/disconnect`, }, (error, response, data) => callback(error, data) ) diff --git a/services/real-time/test/acceptance/js/helpers/RealtimeServer.js b/services/real-time/test/acceptance/js/helpers/RealtimeServer.js index d009a889a6..be3a6f43b8 100644 --- a/services/real-time/test/acceptance/js/helpers/RealtimeServer.js +++ b/services/real-time/test/acceptance/js/helpers/RealtimeServer.js @@ -33,7 +33,7 @@ module.exports = { Settings.internal != null ? Settings.internal.realtime : undefined, x => x.port ), - 'localhost', + '127.0.0.1', error => { if (error != null) { throw error diff --git a/services/real-time/test/acceptance/libs/XMLHttpRequest.js b/services/real-time/test/acceptance/libs/XMLHttpRequest.js index 42c5dd06a7..a6705b2fee 100644 --- a/services/real-time/test/acceptance/libs/XMLHttpRequest.js +++ b/services/real-time/test/acceptance/libs/XMLHttpRequest.js @@ -273,7 +273,7 @@ exports.XMLHttpRequest = function () { case undefined: case '': - host = 'localhost' + host = '127.0.0.1' break default: @@ -309,8 +309,8 @@ exports.XMLHttpRequest = function () { return } - // Default to port 80. If accessing localhost on another port be sure - // to use http://localhost:port/path + // Default to port 80. If accessing 127.0.0.1 on another port be sure + // to use http://127.0.0.1:port/path const port = url.port || (ssl ? 443 : 80) // Add query string if one is used const uri = url.pathname + (url.search ? url.search : '') diff --git a/services/spelling/app.js b/services/spelling/app.js index dba0a0a1e0..fba8c98c24 100644 --- a/services/spelling/app.js +++ b/services/spelling/app.js @@ -7,7 +7,7 @@ import { app } from './app/js/server.js' import * as ASpell from './app/js/ASpell.js' import Metrics from '@overleaf/metrics' -const { host = 'localhost', port = 3005 } = Settings.internal?.spelling ?? {} +const { host = '127.0.0.1', port = 3005 } = Settings.internal?.spelling ?? {} ASpell.startCacheDump() diff --git a/services/spelling/app/js/HealthCheckController.js b/services/spelling/app/js/HealthCheckController.js index 0be86a68be..30def99dba 100644 --- a/services/spelling/app/js/HealthCheckController.js +++ b/services/spelling/app/js/HealthCheckController.js @@ -5,7 +5,7 @@ import OError from '@overleaf/o-error' export function healthCheck(req, res) { const opts = { - url: `http://localhost:3005/user/${settings.healthCheckUserId}/check`, + url: `http://127.0.0.1:3005/user/${settings.healthCheckUserId}/check`, json: { words: ['helllo'], language: 'en', diff --git a/services/spelling/config/settings.defaults.cjs b/services/spelling/config/settings.defaults.cjs index f6a1de94d5..4a27044603 100644 --- a/services/spelling/config/settings.defaults.cjs +++ b/services/spelling/config/settings.defaults.cjs @@ -4,7 +4,7 @@ module.exports = { internal: { spelling: { port: 3005, - host: process.env.LISTEN_ADDRESS || 'localhost', + host: process.env.LISTEN_ADDRESS || '127.0.0.1', }, }, diff --git a/services/spelling/test/acceptance/js/Init.js b/services/spelling/test/acceptance/js/Init.js index bb1f18730f..3288292814 100644 --- a/services/spelling/test/acceptance/js/Init.js +++ b/services/spelling/test/acceptance/js/Init.js @@ -2,5 +2,5 @@ import { app } from '../../../app/js/server.js' import { PORT } from './helpers/request.js' before(function (done) { - return app.listen(PORT, 'localhost', done) + return app.listen(PORT, '127.0.0.1', done) }) diff --git a/services/spelling/test/acceptance/js/helpers/request.js b/services/spelling/test/acceptance/js/helpers/request.js index 40d7b16421..3a16934767 100644 --- a/services/spelling/test/acceptance/js/helpers/request.js +++ b/services/spelling/test/acceptance/js/helpers/request.js @@ -3,7 +3,7 @@ import Request from 'request' export const PORT = 3005 -const BASE_URL = `http://${process.env.HTTP_TEST_HOST || 'localhost'}:${PORT}` +const BASE_URL = `http://${process.env.HTTP_TEST_HOST || '127.0.0.1'}:${PORT}` const request = Request.defaults({ baseUrl: BASE_URL, diff --git a/services/spelling/test/stress/js/stressTest.js b/services/spelling/test/stress/js/stressTest.js index f84e368798..67000308d0 100644 --- a/services/spelling/test/stress/js/stressTest.js +++ b/services/spelling/test/stress/js/stressTest.js @@ -87,7 +87,7 @@ const makeRequest = function (correctWords, incorrectWords, callback) { } } return request.post( - 'http://localhost:3005/user/1/check', + 'http://127.0.0.1:3005/user/1/check', { json: true, body: { words: full } }, function (err, req, body) { let m diff --git a/services/web/app.js b/services/web/app.js index bad8a9aced..4c82e69c9e 100644 --- a/services/web/app.js +++ b/services/web/app.js @@ -48,7 +48,7 @@ if (Settings.catchErrors) { FileWriter.ensureDumpFolderExists() const port = Settings.port || Settings.internal.web.port || 3000 -const host = Settings.internal.web.host || 'localhost' +const host = Settings.internal.web.host || '127.0.0.1' if (!module.parent) { // Called directly diff --git a/services/web/config/settings.defaults.js b/services/web/config/settings.defaults.js index 5dfa6b59b6..01d6b2faee 100644 --- a/services/web/config/settings.defaults.js +++ b/services/web/config/settings.defaults.js @@ -174,7 +174,7 @@ module.exports = { redis: { web: { - host: process.env.REDIS_HOST || 'localhost', + host: process.env.REDIS_HOST || '127.0.0.1', port: process.env.REDIS_PORT || '6379', password: process.env.REDIS_PASSWORD || '', db: process.env.REDIS_DB, @@ -185,36 +185,36 @@ module.exports = { // websessions: // cluster: [ - // {host: 'localhost', port: 7000} - // {host: 'localhost', port: 7001} - // {host: 'localhost', port: 7002} - // {host: 'localhost', port: 7003} - // {host: 'localhost', port: 7004} - // {host: 'localhost', port: 7005} + // {host: '127.0.0.1', port: 7000} + // {host: '127.0.0.1', port: 7001} + // {host: '127.0.0.1', port: 7002} + // {host: '127.0.0.1', port: 7003} + // {host: '127.0.0.1', port: 7004} + // {host: '127.0.0.1', port: 7005} // ] // ratelimiter: // cluster: [ - // {host: 'localhost', port: 7000} - // {host: 'localhost', port: 7001} - // {host: 'localhost', port: 7002} - // {host: 'localhost', port: 7003} - // {host: 'localhost', port: 7004} - // {host: 'localhost', port: 7005} + // {host: '127.0.0.1', port: 7000} + // {host: '127.0.0.1', port: 7001} + // {host: '127.0.0.1', port: 7002} + // {host: '127.0.0.1', port: 7003} + // {host: '127.0.0.1', port: 7004} + // {host: '127.0.0.1', port: 7005} // ] // cooldown: // cluster: [ - // {host: 'localhost', port: 7000} - // {host: 'localhost', port: 7001} - // {host: 'localhost', port: 7002} - // {host: 'localhost', port: 7003} - // {host: 'localhost', port: 7004} - // {host: 'localhost', port: 7005} + // {host: '127.0.0.1', port: 7000} + // {host: '127.0.0.1', port: 7001} + // {host: '127.0.0.1', port: 7002} + // {host: '127.0.0.1', port: 7003} + // {host: '127.0.0.1', port: 7004} + // {host: '127.0.0.1', port: 7005} // ] api: { - host: process.env.REDIS_HOST || 'localhost', + host: process.env.REDIS_HOST || '127.0.0.1', port: process.env.REDIS_PORT || '6379', password: process.env.REDIS_PASSWORD || '', maxRetriesPerRequest: parseInt( @@ -232,7 +232,7 @@ module.exports = { internal: { web: { port: process.env.WEB_PORT || 3000, - host: process.env.LISTEN_ADDRESS || 'localhost', + host: process.env.LISTEN_ADDRESS || '127.0.0.1', }, }, @@ -242,7 +242,7 @@ module.exports = { apis: { web: { url: `http://${ - process.env.WEB_API_HOST || process.env.WEB_HOST || 'localhost' + process.env.WEB_API_HOST || process.env.WEB_HOST || '127.0.0.1' }:${process.env.WEB_API_PORT || process.env.WEB_PORT || 3000}`, user: httpAuthUser, pass: httpAuthPass, @@ -251,25 +251,25 @@ module.exports = { url: `http://${ process.env.DOCUPDATER_HOST || process.env.DOCUMENT_UPDATER_HOST || - 'localhost' + '127.0.0.1' }:3003`, }, spelling: { - url: `http://${process.env.SPELLING_HOST || 'localhost'}:3005`, + url: `http://${process.env.SPELLING_HOST || '127.0.0.1'}:3005`, host: process.env.SPELLING_HOST, }, docstore: { - url: `http://${process.env.DOCSTORE_HOST || 'localhost'}:3016`, - pubUrl: `http://${process.env.DOCSTORE_HOST || 'localhost'}:3016`, + url: `http://${process.env.DOCSTORE_HOST || '127.0.0.1'}:3016`, + pubUrl: `http://${process.env.DOCSTORE_HOST || '127.0.0.1'}:3016`, }, chat: { - internal_url: `http://${process.env.CHAT_HOST || 'localhost'}:3010`, + internal_url: `http://${process.env.CHAT_HOST || '127.0.0.1'}:3010`, }, filestore: { - url: `http://${process.env.FILESTORE_HOST || 'localhost'}:3009`, + url: `http://${process.env.FILESTORE_HOST || '127.0.0.1'}:3009`, }, clsi: { - url: `http://${process.env.CLSI_HOST || 'localhost'}:3013`, + url: `http://${process.env.CLSI_HOST || '127.0.0.1'}:3013`, // url: "http://#{process.env['CLSI_LB_HOST']}:3014" backendGroupName: undefined, submissionBackendClass: @@ -277,19 +277,19 @@ module.exports = { }, project_history: { sendProjectStructureOps: true, - url: `http://${process.env.PROJECT_HISTORY_HOST || 'localhost'}:3054`, + url: `http://${process.env.PROJECT_HISTORY_HOST || '127.0.0.1'}:3054`, }, realTime: { - url: `http://${process.env.REALTIME_HOST || 'localhost'}:3026`, + url: `http://${process.env.REALTIME_HOST || '127.0.0.1'}:3026`, }, contacts: { - url: `http://${process.env.CONTACTS_HOST || 'localhost'}:3036`, + url: `http://${process.env.CONTACTS_HOST || '127.0.0.1'}:3036`, }, notifications: { - url: `http://${process.env.NOTIFICATIONS_HOST || 'localhost'}:3042`, + url: `http://${process.env.NOTIFICATIONS_HOST || '127.0.0.1'}:3042`, }, webpack: { - url: `http://${process.env.WEBPACK_HOST || 'localhost'}:3808`, + url: `http://${process.env.WEBPACK_HOST || '127.0.0.1'}:3808`, }, wiki: { url: process.env.WIKI_URL || 'https://learn.sharelatex.com', @@ -328,7 +328,7 @@ module.exports = { // Where your instance of Overleaf Community Edition/Server Pro can be found publicly. Used in emails // that are sent out, generated links, etc. - siteUrl: (siteUrl = process.env.PUBLIC_URL || 'http://localhost:3000'), + siteUrl: (siteUrl = process.env.PUBLIC_URL || 'http://127.0.0.1:3000'), lockManager: { lockTestInterval: intFromEnv('LOCK_MANAGER_LOCK_TEST_INTERVAL', 50), diff --git a/services/web/docker-compose.common.env b/services/web/docker-compose.common.env index 10e60cbd31..666857d0df 100644 --- a/services/web/docker-compose.common.env +++ b/services/web/docker-compose.common.env @@ -6,7 +6,7 @@ QUEUES_REDIS_HOST=redis ANALYTICS_QUEUES_REDIS_HOST=redis MONGO_URL=mongodb://mongo/test-overleaf OVERLEAF_ALLOW_PUBLIC_ACCESS=true -LINKED_URL_PROXY=http://localhost:6543 +LINKED_URL_PROXY=http://127.0.0.1:6543 ENABLED_LINKED_FILE_TYPES=url,project_file,project_output_file,mendeley,zotero NODE_ENV=test NODE_OPTIONS=--unhandled-rejections=strict @@ -17,7 +17,7 @@ PUBLIC_URL=http://www.overleaf.test:23000 HTTP_TEST_HOST=www.overleaf.test OT_JWT_AUTH_KEY="very secret key" EXTERNAL_AUTH=none -RECAPTCHA_ENDPOINT=http://localhost:2222/recaptcha/api/siteverify +RECAPTCHA_ENDPOINT=http://127.0.0.1:2222/recaptcha/api/siteverify # Server-Pro LDAP OVERLEAF_LDAP_URL=ldap://ldap:389 OVERLEAF_LDAP_SEARCH_BASE=ou=people,dc=planetexpress,dc=com diff --git a/services/web/local-test.env b/services/web/local-test.env index 428915c58d..ff6fabe866 100644 --- a/services/web/local-test.env +++ b/services/web/local-test.env @@ -14,5 +14,5 @@ OVERLEAF_SAML_ENTRYPOINT=http://127.0.0.1:22280/simplesaml/saml2/idp/SSOService. OVERLEAF_SAML_CALLBACK_URL=http://127.0.0.1:22280/saml/callback COOKIE_DOMAIN= -PUBLIC_URL=http://localhost:23000 -HTTP_TEST_HOST=localhost +PUBLIC_URL=http://127.0.0.1:23000 +HTTP_TEST_HOST=127.0.0.1 diff --git a/services/web/modules/server-ce-scripts/test/acceptance/src/ServerCEScriptsTests.js b/services/web/modules/server-ce-scripts/test/acceptance/src/ServerCEScriptsTests.js index 29b66bf1d8..a12ed31704 100644 --- a/services/web/modules/server-ce-scripts/test/acceptance/src/ServerCEScriptsTests.js +++ b/services/web/modules/server-ce-scripts/test/acceptance/src/ServerCEScriptsTests.js @@ -34,7 +34,7 @@ describe('ServerCEScripts', function () { try { run( 'MONGO_SERVER_SELECTION_TIMEOUT=1' + - 'MONGO_CONNECTION_STRING=mongodb://localhost:4242 ' + + 'MONGO_CONNECTION_STRING=mongodb://127.0.0.1:4242 ' + 'node modules/server-ce-scripts/scripts/check-mongodb' ) } catch (e) { diff --git a/services/web/test/acceptance/config/settings.test.defaults.js b/services/web/test/acceptance/config/settings.test.defaults.js index c97e5abd17..7f8ed923d4 100644 --- a/services/web/test/acceptance/config/settings.test.defaults.js +++ b/services/web/test/acceptance/config/settings.test.defaults.js @@ -41,58 +41,58 @@ module.exports = { }, web: { - url: 'http://localhost:23000', + url: 'http://127.0.0.1:23000', user: httpAuthUser, pass: httpAuthPass, }, haveIBeenPwned: { enabled: false, - url: 'http://localhost:1337', + url: 'http://127.0.0.1:1337', }, documentupdater: { - url: 'http://localhost:23003', + url: 'http://127.0.0.1:23003', }, spelling: { - url: 'http://localhost:23005', - host: 'localhost', + url: 'http://127.0.0.1:23005', + host: '127.0.0.1', }, docstore: { - url: 'http://localhost:23016', - pubUrl: 'http://localhost:23016', + url: 'http://127.0.0.1:23016', + pubUrl: 'http://127.0.0.1:23016', }, chat: { - internal_url: 'http://localhost:23010', + internal_url: 'http://127.0.0.1:23010', }, filestore: { - url: 'http://localhost:23009', + url: 'http://127.0.0.1:23009', }, clsi: { - url: 'http://localhost:23013', + url: 'http://127.0.0.1:23013', }, realTime: { - url: 'http://localhost:23026', + url: 'http://127.0.0.1:23026', }, contacts: { - url: 'http://localhost:23036', + url: 'http://127.0.0.1:23036', }, notifications: { - url: 'http://localhost:23042', + url: 'http://127.0.0.1:23042', }, project_history: { sendProjectStructureOps: true, - url: `http://localhost:23054`, + url: `http://127.0.0.1:23054`, }, v1_history: { - url: `http://localhost:23100/api`, + url: `http://127.0.0.1:23100/api`, user: 'overleaf', pass: 'password', }, webpack: { - url: 'http://localhost:23808', + url: 'http://127.0.0.1:23808', }, gitBridge: { - url: 'http://localhost:28000', + url: 'http://127.0.0.1:28000', }, }, diff --git a/services/web/test/acceptance/config/settings.test.saas.js b/services/web/test/acceptance/config/settings.test.saas.js index b3ff8462b3..c33c4aa8f5 100644 --- a/services/web/test/acceptance/config/settings.test.saas.js +++ b/services/web/test/acceptance/config/settings.test.saas.js @@ -12,13 +12,13 @@ const overrides = { apis: { thirdPartyDataStore: { - url: `http://localhost:23002`, + url: `http://127.0.0.1:23002`, }, analytics: { - url: `http://localhost:23050`, + url: `http://127.0.0.1:23050`, }, recurly: { - url: 'http://localhost:26034', + url: 'http://127.0.0.1:26034', subdomain: 'test', apiKey: 'private-nonsense', webhookUser: 'recurly', @@ -31,7 +31,7 @@ const overrides = { }, v1: { - url: `http://localhost:25000`, + url: `http://127.0.0.1:25000`, user: 'overleaf', pass: 'password', }, @@ -66,7 +66,7 @@ const overrides = { module.exports = baseApp.mergeWith(baseTest.mergeWith(overrides)) for (const redisKey of Object.keys(module.exports.redis)) { - module.exports.redis[redisKey].host = process.env.REDIS_HOST || 'localhost' + module.exports.redis[redisKey].host = process.env.REDIS_HOST || '127.0.0.1' } module.exports.mergeWith = function (overrides) { diff --git a/services/web/test/acceptance/src/HttpPermissionsPolicyTests.js b/services/web/test/acceptance/src/HttpPermissionsPolicyTests.js index c4d2fe21fa..563fe6b974 100644 --- a/services/web/test/acceptance/src/HttpPermissionsPolicyTests.js +++ b/services/web/test/acceptance/src/HttpPermissionsPolicyTests.js @@ -2,7 +2,7 @@ const { expect } = require('chai') const fetch = require('node-fetch') const Settings = require('@overleaf/settings') -const BASE_URL = `http://${process.env.HTTP_TEST_HOST || 'localhost'}:23000` +const BASE_URL = `http://${process.env.HTTP_TEST_HOST || '127.0.0.1'}:23000` describe('HttpPermissionsPolicy', function () { it('should have permissions-policy header on user-facing pages', async function () { diff --git a/services/web/test/acceptance/src/LinkedFilesTests.js b/services/web/test/acceptance/src/LinkedFilesTests.js index 6a67455062..c111035ee9 100644 --- a/services/web/test/acceptance/src/LinkedFilesTests.js +++ b/services/web/test/acceptance/src/LinkedFilesTests.js @@ -370,7 +370,7 @@ describe('LinkedFiles', function () { json: { provider: 'url', data: { - url: 'ftp://localhost', + url: 'ftp://127.0.0.1', }, parent_folder_id: projectOneRootFolderId, name: 'url-test-file-5', diff --git a/services/web/test/acceptance/src/helpers/UserHelper.js b/services/web/test/acceptance/src/helpers/UserHelper.js index a9c57f85a4..661b27758e 100644 --- a/services/web/test/acceptance/src/helpers/UserHelper.js +++ b/services/web/test/acceptance/src/helpers/UserHelper.js @@ -217,7 +217,7 @@ class UserHelper { * @returns {string} baseUrl */ static baseUrl() { - return `http://${process.env.HTTP_TEST_HOST || 'localhost'}:23000` + return `http://${process.env.HTTP_TEST_HOST || '127.0.0.1'}:23000` } /** diff --git a/services/web/test/acceptance/src/helpers/request.js b/services/web/test/acceptance/src/helpers/request.js index e393d389ea..16f8db0700 100644 --- a/services/web/test/acceptance/src/helpers/request.js +++ b/services/web/test/acceptance/src/helpers/request.js @@ -1,6 +1,6 @@ // TODO: This file was created by bulk-decaffeinate. // Sanity-check the conversion and remove this comment. -const BASE_URL = `http://${process.env.HTTP_TEST_HOST || 'localhost'}:23000` +const BASE_URL = `http://${process.env.HTTP_TEST_HOST || '127.0.0.1'}:23000` const request = require('request').defaults({ baseUrl: BASE_URL, followRedirect: false, diff --git a/services/web/test/acceptance/src/mocks/MockV1HistoryApi.js b/services/web/test/acceptance/src/mocks/MockV1HistoryApi.js index 204c6a148b..0b8e4b06c8 100644 --- a/services/web/test/acceptance/src/mocks/MockV1HistoryApi.js +++ b/services/web/test/acceptance/src/mocks/MockV1HistoryApi.js @@ -70,7 +70,7 @@ class MockV1HistoryApi extends AbstractMockApi { this.requestedZipPacks++ this.events.emit('v1-history-pack-zip') res.json({ - zipUrl: `http://localhost:23100/fake-zip-download/${req.params.project_id}/version/${req.params.version}`, + zipUrl: `http://127.0.0.1:23100/fake-zip-download/${req.params.project_id}/version/${req.params.version}`, }) } ) diff --git a/services/web/test/frontend/bootstrap.js b/services/web/test/frontend/bootstrap.js index 8f7eec183e..676d8ad2f3 100644 --- a/services/web/test/frontend/bootstrap.js +++ b/services/web/test/frontend/bootstrap.js @@ -129,7 +129,7 @@ const fetch = require('node-fetch') globalThis.fetch = global.fetch = window.fetch = - (url, ...options) => fetch(new URL(url, 'http://localhost'), ...options) + (url, ...options) => fetch(new URL(url, 'http://127.0.0.1'), ...options) // ignore CSS files const { addHook } = require('pirates') diff --git a/services/web/test/unit/src/Compile/CompileManagerTests.js b/services/web/test/unit/src/Compile/CompileManagerTests.js index 8cfca421d7..8a6a613db8 100644 --- a/services/web/test/unit/src/Compile/CompileManagerTests.js +++ b/services/web/test/unit/src/Compile/CompileManagerTests.js @@ -25,7 +25,7 @@ describe('CompileManager', function () { apis: { clsi: { submissionBackendClass: 'n2d' }, }, - redis: { web: { host: 'localhost', port: 42 } }, + redis: { web: { host: '127.0.0.1', port: 42 } }, rateLimit: { autoCompile: {} }, }), '../../infrastructure/RedisWrapper': { diff --git a/services/web/test/unit/src/Exports/ExportsHandlerTests.js b/services/web/test/unit/src/Exports/ExportsHandlerTests.js index 454fc7eb61..3362b4d4e1 100644 --- a/services/web/test/unit/src/Exports/ExportsHandlerTests.js +++ b/services/web/test/unit/src/Exports/ExportsHandlerTests.js @@ -503,7 +503,7 @@ describe('ExportsHandler', function () { beforeEach(function (done) { this.settings.apis = { v1: { - url: 'http://localhost:5000', + url: 'http://127.0.0.1:5000', user: 'overleaf', pass: 'pass', timeout: 15000, @@ -596,7 +596,7 @@ describe('ExportsHandler', function () { beforeEach(function (done) { this.settings.apis = { v1: { - url: 'http://localhost:5000', + url: 'http://127.0.0.1:5000', user: 'overleaf', pass: 'pass', timeout: 15000, @@ -648,7 +648,7 @@ describe('ExportsHandler', function () { beforeEach(function (done) { this.settings.apis = { v1: { - url: 'http://localhost:5000', + url: 'http://127.0.0.1:5000', user: 'overleaf', pass: 'pass', timeout: 15000, diff --git a/services/web/test/unit/src/HelperFiles/UrlHelperTests.js b/services/web/test/unit/src/HelperFiles/UrlHelperTests.js index 832ece1d6b..455b99d36b 100644 --- a/services/web/test/unit/src/HelperFiles/UrlHelperTests.js +++ b/services/web/test/unit/src/HelperFiles/UrlHelperTests.js @@ -9,7 +9,7 @@ describe('UrlHelper', function () { beforeEach(function () { this.settings = { apis: { linkedUrlProxy: { url: undefined } }, - siteUrl: 'http://localhost:3000', + siteUrl: 'http://127.0.0.1:3000', } this.UrlHelper = SandboxedModule.require(modulePath, { requires: { '@overleaf/settings': this.settings }, diff --git a/services/web/test/unit/src/Templates/TemplatesManagerTests.js b/services/web/test/unit/src/Templates/TemplatesManagerTests.js index 9e01f73e27..f75827094d 100644 --- a/services/web/test/unit/src/Templates/TemplatesManagerTests.js +++ b/services/web/test/unit/src/Templates/TemplatesManagerTests.js @@ -101,7 +101,7 @@ describe('TemplatesManager', function () { path: { dumpFolder: this.dumpFolder, }, - siteUrl: (this.siteUrl = 'http://localhost:3000'), + siteUrl: (this.siteUrl = 'http://127.0.0.1:3000'), apis: { v1: { url: (this.v1Url = 'http://overleaf.com'), diff --git a/services/web/test/unit/src/ThirdPartyDataStore/TpdsUpdateSenderTests.js b/services/web/test/unit/src/ThirdPartyDataStore/TpdsUpdateSenderTests.js index 5c528a6350..70c48d8255 100644 --- a/services/web/test/unit/src/ThirdPartyDataStore/TpdsUpdateSenderTests.js +++ b/services/web/test/unit/src/ThirdPartyDataStore/TpdsUpdateSenderTests.js @@ -16,7 +16,7 @@ const collaberatorRef = new ObjectId() const projectName = 'project_name_here' const thirdPartyDataStoreApiUrl = 'http://third-party-json-store.herokuapp.com' -const siteUrl = 'http://www.localhost:3000' +const siteUrl = 'http://127.0.0.1:3000' const filestoreUrl = 'filestore.overleaf.com' describe('TpdsUpdateSender', function () {