Skip to content
This repository has been archived by the owner on Aug 21, 2019. It is now read-only.

try to detect proxy based on env variables #24

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion mailgun.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Mailgun.prototype = {};

// Utility method to set up required http options.
Mailgun.prototype._createHttpOptions = function(resource, method, servername) {
return {
var options = {
host: 'api.mailgun.net',
port: 443,
method: method,
Expand All @@ -71,6 +71,12 @@ Mailgun.prototype._createHttpOptions = function(resource, method, servername) {
'Authorization': 'Basic ' + this._apiKey64
}
};
var proxyServer = process.env.http_proxy || process.env.HTTP_PROXY || process.env.https_proxy || process.env.HTTPS_PROXY || false;
if (proxyServer !== false && proxyServer !== '') {
var HttpsProxyAgent = require('https-proxy-agent');
options.agent = new HttpsProxyAgent(proxyServer);
}
return options;
}

//
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
"url": "[email protected]:shz/node-mailgun.git"
},
"main": "./mailgun",
"dependencies": {
"https-proxy-agent": "~1.0.0"
},
"homepage": "http://github.com/shz/node-mailgun",
"engine": "node"
}