Skip to content

Commit

Permalink
Fix require failure in browser code due to proxy library
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Clark committed Aug 27, 2015
1 parent fae5c74 commit 30d5134
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions Gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ function webpackConfig(extension, overrides) {
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader?optional=runtime'
}, {
test: /\.json/,
loader: 'json-loader'
}]
}
};
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"gulp-rename": "~1.2.0",
"gulp-uglify": "~1.1.0",
"istanbul": "~0.3.5",
"json-loader": "^0.5.2",
"mocha": "~2.1.0",
"webpack": "~1.5.3",
"yargs": "~1.3.1"
Expand Down
7 changes: 6 additions & 1 deletion src/core/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const _ = require('lodash');
const assert = require('assert');
const util = require('util');
const url = require('url');
const HttpsProxyAgent = require('https-proxy-agent');
const LRU = require('lru-cache');
const EventEmitter = require('events').EventEmitter;
const RippleError = require('./rippleerror').RippleError;
Expand Down Expand Up @@ -447,6 +446,12 @@ Server.prototype.connect = function() {
const parsed = url.parse(this._opts.url);
const opts = url.parse(this._remote.proxy);
opts.secureEndpoint = parsed.protocol === 'wss:';
let HttpsProxyAgent;
try {
HttpsProxyAgent = require('https-proxy-agent');
} catch (error) {
throw new Error('"proxy" option is not supported in the browser');
}
const agent = new HttpsProxyAgent(opts);

this._ws = new WebSocket(this._opts.url, {agent: agent});
Expand Down

0 comments on commit 30d5134

Please sign in to comment.