mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-18 19:25:48 +00:00
Fix require failure in browser code due to proxy library
This commit is contained in:
@@ -26,6 +26,9 @@ function webpackConfig(extension, overrides) {
|
||||
test: /\.js$/,
|
||||
exclude: /node_modules/,
|
||||
loader: 'babel-loader?optional=runtime'
|
||||
}, {
|
||||
test: /\.json/,
|
||||
loader: 'json-loader'
|
||||
}]
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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;
|
||||
@@ -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});
|
||||
|
||||
Reference in New Issue
Block a user