Skip to content

Commit 676d423

Browse files
committed
Explicitly use 127.0.0.1 instead of localhost
Bizarrely, some users seem to have localhost resolving incorrectly, which blocks server startup. They may still hit issues after this change, but the result should be clearer, and may be fixable with pure UI changes later.
1 parent 4b561c0 commit 676d423

File tree

5 files changed

+16
-16
lines changed

5 files changed

+16
-16
lines changed

src/httptoolkit-server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ export class HttpToolkitServer extends events.EventEmitter {
178178
await this.graphql.start(<any> {
179179
// Hacky solution that lets us limit the server to only localhost,
180180
// and override the port from 4000 to something less likely to conflict.
181-
port: { port: 45457, host: 'localhost' },
181+
port: { port: 45457, host: '127.0.0.1' },
182182
playground: false,
183183
cors: { origin: ALLOWED_ORIGINS }
184184
});

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export async function runHTK(options: {
7474
});
7575
standalone.start({
7676
port: 45456,
77-
host: 'localhost'
77+
host: '127.0.0.1'
7878
});
7979

8080
// Start a HTK server

src/interceptors/fresh-chrome.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export class FreshChrome implements Interceptor {
5252
// Try to launch Chrome if we're not sure - it'll trigger a config update,
5353
// and might find a new install.
5454
browser: (await getChromeBrowserName(this.config)) || 'chrome',
55-
proxy: `https://localhost:${proxyPort}`,
55+
proxy: `https://127.0.0.1:${proxyPort}`,
5656
noProxy: [
5757
// Don't intercept our warning hiding requests
5858
hideWarningServer.host,

src/interceptors/fresh-firefox.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,17 +73,17 @@ export class FreshFirefox implements Interceptor {
7373
const browser = await launchBrowser(certCheckServer.checkCertUrl, {
7474
browser: 'firefox',
7575
profile: firefoxProfile,
76-
proxy: `localhost:${proxyPort}`,
76+
proxy: `127.0.0.1:${proxyPort}`,
7777
// Don't intercept our cert testing requests
7878
noProxy: certCheckServer.host,
7979
prefs: _.assign(existingPrefs, {
80-
// By default james-launcher only configures HTTP, so we need to add HTTPS:
81-
'network.proxy.ssl': '"localhost"',
80+
// By default browser-launcher only configures HTTP, so we need to add HTTPS:
81+
'network.proxy.ssl': '"127.0.0.1"',
8282
'network.proxy.ssl_port': proxyPort,
8383

84-
// The above james proxy/noProxy settings should do this, but don't seem to
84+
// The above browser-launcher proxy/noProxy settings should do this, but don't seem to
8585
// reliably overwrite existing values, so we set them explicitly.
86-
'network.proxy.http': '"localhost"',
86+
'network.proxy.http': '"127.0.0.1"',
8787
'network.proxy.http_port': proxyPort,
8888
'network.proxy.http.network.proxy.http.no_proxies_on': certCheckServer.host,
8989

src/interceptors/terminal/terminal-env-overrides.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@ export function getTerminalEnvVars(
1616
currentEnv: { [key: string]: string | undefined }
1717
): { [key: string]: string } {
1818
return {
19-
'http_proxy': `http://localhost:${proxyPort}`,
20-
'HTTP_PROXY': `http://localhost:${proxyPort}`,
21-
'https_proxy': `http://localhost:${proxyPort}`,
22-
'HTTPS_PROXY': `http://localhost:${proxyPort}`,
19+
'http_proxy': `http://127.0.0.1:${proxyPort}`,
20+
'HTTP_PROXY': `http://127.0.0.1:${proxyPort}`,
21+
'https_proxy': `http://127.0.0.1:${proxyPort}`,
22+
'HTTPS_PROXY': `http://127.0.0.1:${proxyPort}`,
2323
// Used by global-agent to configure node.js HTTP(S) defaults
24-
'GLOBAL_AGENT_HTTP_PROXY': `http://localhost:${proxyPort}`,
24+
'GLOBAL_AGENT_HTTP_PROXY': `http://127.0.0.1:${proxyPort}`,
2525
// Used by some CGI engines to avoid 'httpoxy' vulnerability
26-
'CGI_HTTP_PROXY': `http://localhost:${proxyPort}`,
26+
'CGI_HTTP_PROXY': `http://127.0.0.1:${proxyPort}`,
2727
// Used by npm, for versions that don't support HTTP_PROXY etc
28-
'npm_config_proxy': `http://localhost:${proxyPort}`,
29-
'npm_config_https_proxy': `http://localhost:${proxyPort}`,
28+
'npm_config_proxy': `http://127.0.0.1:${proxyPort}`,
29+
'npm_config_https_proxy': `http://127.0.0.1:${proxyPort}`,
3030
// Stop npm warning about having a different 'node' in $PATH
3131
'npm_config_scripts_prepend_node_path': 'false',
3232

0 commit comments

Comments
 (0)