-
Couldn't load subscription status.
- Fork 64
Description
Issue Summary
We are using twilio-run behind an https proxy. Running twilio-run deploy hangs at Configuring bare environment and eventually times out with a failed request. This is because the got http client used by serverless-api does not use the HTTP_PROXY environment variable to set an http agent (see sindresorhus/got#79 and sindresorhus/got#7). This makes the requests not issue CONNECTs. This issue is similar to twilio/twilio-cli#223.
Steps to Reproduce
- Have a locally running forward proxy
- Be on a network behind a https authenticating proxy
- Run
twilio-run deployon a twilio function
Reproduce behaviour
This will cause a GET to be sent to the forward proxy.
const got = require('got');
got('https://www.twilio.com')
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
})
.then(function () {
});
Suggested fix
The recommended fix from got docs is to add an http agent to the got client using the hpagent package.
This will cause a CONNECT to be sent to the forward proxy.
const got = require('got');
const hpagent = require('hpagent');
got('https://www.twilio.com', {
agent: {
https: new hpagent.HttpsProxyAgent({
proxy: process.env.HTTP_PROXY,
}),
}
})
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
})
.then(function () {
});
The impacted code is in the serverless-api package: https://github.com/twilio-labs/serverless-toolkit/blob/main/packages/serverless-api/src/client.ts.