Files
cypress/packages/server/lib/util/proxy.js
Zach Bloomquist 818dfdfd00 Revert "server, launcher, ts: typescript"
This reverts commit d3f8b8bbb6.
2019-03-26 17:14:21 -04:00

43 lines
1.1 KiB
JavaScript

const os = require('os')
const getWindowsProxy = require('@cypress/get-windows-proxy')
module.exports = {
_getWindowsProxy () {
return getWindowsProxy()
},
_normalizeEnvironmentProxy () {
if (!process.env.HTTPS_PROXY) {
// request library will use HTTP_PROXY as a fallback for HTTPS urls, but
// proxy-from-env will not, so let's just force it to fall back like this
process.env.HTTPS_PROXY = process.env.HTTP_PROXY
}
if (!process.env.NO_PROXY) {
// don't proxy localhost, to match Chrome's default behavior and user expectation
process.env.NO_PROXY = 'localhost'
}
},
loadSystemProxySettings () {
if (process.env.HTTP_PROXY !== undefined) {
this._normalizeEnvironmentProxy()
return
}
if (os.platform() === 'win32') {
const windowsProxy = this._getWindowsProxy()
if (windowsProxy) {
process.env.HTTP_PROXY = process.env.HTTPS_PROXY = windowsProxy.httpProxy
process.env.NO_PROXY = process.env.NO_PROXY || windowsProxy.noProxy
}
this._normalizeEnvironmentProxy()
return 'win32'
}
},
}