diff --git a/dist/bundle.es.js b/dist/bundle.es.js index de8a54b..b538929 100644 --- a/dist/bundle.es.js +++ b/dist/bundle.es.js @@ -884,6 +884,8 @@ const Lbry = { isConnected: false, connectPromise: null, daemonConnectionString: 'http://localhost:5279', + alternateConnectionString: '', + methodsUsingAlternateConnectionString: [], apiRequestHeaders: { 'Content-Type': 'application/json-rpc' }, // Allow overriding daemon connection string (e.g. to `/api/proxy` for lbryweb) @@ -1052,7 +1054,8 @@ function apiCall(method, params, resolve, reject) { }) }; - return fetch(Lbry.daemonConnectionString + '?m=' + method, options).then(checkAndParse).then(response => { + const connectionString = Lbry.methodsUsingAlternateConnectionString.includes(method) ? Lbry.alternateConnectionString : Lbry.daemonConnectionString; + return fetch(connectionString + '?m=' + method, options).then(checkAndParse).then(response => { const error = response.error || response.result && response.result.error; if (error) { diff --git a/dist/flow-typed/Lbry.js b/dist/flow-typed/Lbry.js index ba88d27..9f43627 100644 --- a/dist/flow-typed/Lbry.js +++ b/dist/flow-typed/Lbry.js @@ -221,6 +221,8 @@ declare type LbryTypes = { connectPromise: ?Promise, connect: () => void, daemonConnectionString: string, + alternateConnectionString: string, + methodsUsingAlternateConnectionString: Array, apiRequestHeaders: { [key: string]: string }, setDaemonConnectionString: string => void, setApiHeader: (string, string) => void, diff --git a/flow-typed/Lbry.js b/flow-typed/Lbry.js index ba88d27..9f43627 100644 --- a/flow-typed/Lbry.js +++ b/flow-typed/Lbry.js @@ -221,6 +221,8 @@ declare type LbryTypes = { connectPromise: ?Promise, connect: () => void, daemonConnectionString: string, + alternateConnectionString: string, + methodsUsingAlternateConnectionString: Array, apiRequestHeaders: { [key: string]: string }, setDaemonConnectionString: string => void, setApiHeader: (string, string) => void, diff --git a/src/lbry.js b/src/lbry.js index 146149d..33b57c0 100644 --- a/src/lbry.js +++ b/src/lbry.js @@ -11,6 +11,8 @@ const Lbry: LbryTypes = { isConnected: false, connectPromise: null, daemonConnectionString: 'http://localhost:5279', + alternateConnectionString: '', + methodsUsingAlternateConnectionString: [], apiRequestHeaders: { 'Content-Type': 'application/json-rpc' }, // Allow overriding daemon connection string (e.g. to `/api/proxy` for lbryweb) @@ -191,7 +193,10 @@ export function apiCall(method: string, params: ?{}, resolve: Function, reject: }), }; - return fetch(Lbry.daemonConnectionString + '?m=' + method, options) + const connectionString = Lbry.methodsUsingAlternateConnectionString.includes(method) + ? Lbry.alternateConnectionString + : Lbry.daemonConnectionString; + return fetch(connectionString + '?m=' + method, options) .then(checkAndParse) .then(response => { const error = response.error || (response.result && response.result.error);