Skip to content

Commit

Permalink
Added support for API hosts with non-standard ports. Previously an AP…
Browse files Browse the repository at this point in the history
…I host of "localhost:8080" would actually set "localhost:8080" as the 'host' option to the AJAX request. This would fail horribly. Now the port is split out and passed as the 'port' option to the request. If no ":<port>" is provided, Node will use the protocol default, if any.
  • Loading branch information
adamkaplan committed Sep 13, 2011
1 parent 6db92c9 commit 5e9f9d4
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,12 +298,17 @@ function processRequest(req, res, next) {
}
}

var baseHostInfo = apiConfig.baseURL.split(':');
var baseHostUrl = baseHostInfo[0],
baseHostPort = (baseHostInfo.length > 1) ? baseHostInfo[1] : "";

var paramString = query.stringify(params),
privateReqURL = apiConfig.protocol + '://' + apiConfig.baseURL + apiConfig.privatePath + methodURL + ((paramString.length > 0) ? '?' + paramString : ""),
options = {
headers: {},
protocol: apiConfig.protocol,
host: apiConfig.baseURL,
host: baseHostUrl,
port: baseHostPort,
method: httpMethod,
path: apiConfig.publicPath + methodURL + ((paramString.length > 0) ? '?' + paramString : "")
};
Expand Down

0 comments on commit 5e9f9d4

Please sign in to comment.