diff --git a/js/src/dapps/registry/ui/image.js b/js/src/dapps/registry/ui/image.js index 7e7a52a88..e0101e1f2 100644 --- a/js/src/dapps/registry/ui/image.js +++ b/js/src/dapps/registry/ui/image.js @@ -16,6 +16,8 @@ import React from 'react'; +import { parityNode } from '../../../environment'; + const styles = { padding: '.5em', border: '1px solid #777' @@ -23,7 +25,7 @@ const styles = { export default (address) => ( { diff --git a/js/src/dapps/tokenreg/Tokens/Token/token.js b/js/src/dapps/tokenreg/Tokens/Token/token.js index bee925689..18942b085 100644 --- a/js/src/dapps/tokenreg/Tokens/Token/token.js +++ b/js/src/dapps/tokenreg/Tokens/Token/token.js @@ -30,6 +30,7 @@ import styles from './token.css'; import { metaDataKeys } from '../../constants'; import { api } from '../../parity'; +import { parityNode } from '../../../../environment'; export default class Token extends Component { static propTypes = { @@ -267,7 +268,7 @@ export default class Token extends Component { meta-data:

- +
); } diff --git a/js/src/environment/index.js b/js/src/environment/index.js index d8e81f343..1dfda77aa 100644 --- a/js/src/environment/index.js +++ b/js/src/environment/index.js @@ -18,3 +18,9 @@ // import './perf-debug'; import './tests'; + +const parityNode = process.env.NODE_ENV === 'production' ? 'http://127.0.0.1:8080' : ''; + +export { + parityNode +}; diff --git a/js/src/index.js b/js/src/index.js index 08b02c2a3..24649b026 100644 --- a/js/src/index.js +++ b/js/src/index.js @@ -17,12 +17,6 @@ import 'babel-polyfill'; import 'whatwg-fetch'; -// redirect when not on 127.0.0.1:8180 -const host = `${window.location.hostname}:${window.location.port}`; -if (host === '127.0.0.1:8080' || host === 'localhost:8080') { - window.location = 'http://127.0.0.1:8180'; -} - import es6Promise from 'es6-promise'; es6Promise.polyfill(); diff --git a/js/src/redux/providers/imagesReducer.js b/js/src/redux/providers/imagesReducer.js index e3e8cbbfc..15745932d 100644 --- a/js/src/redux/providers/imagesReducer.js +++ b/js/src/redux/providers/imagesReducer.js @@ -17,6 +17,8 @@ import { handleActions } from 'redux-actions'; import { bytesToHex } from '../../api/util/format'; +import { parityNode } from '../../environment'; + const ZERO = '0x0000000000000000000000000000000000000000000000000000000000000000'; const initialState = { @@ -26,7 +28,7 @@ const initialState = { export function hashToImageUrl (hashArray) { const hash = hashArray ? bytesToHex(hashArray) : ZERO; - return hash === ZERO ? null : `http://127.0.0.1:8080/api/content/${hash.substr(2)}`; + return hash === ZERO ? null : `${parityNode}/api/content/${hash.substr(2)}`; } export default handleActions({ diff --git a/js/src/redux/providers/status.js b/js/src/redux/providers/status.js index 2e039134b..8d5874698 100644 --- a/js/src/redux/providers/status.js +++ b/js/src/redux/providers/status.js @@ -16,6 +16,8 @@ import { statusBlockNumber, statusCollection, statusLogs } from './statusActions'; +import { parityNode } from '../../environment'; + export default class Status { constructor (store, api) { this._api = api; @@ -49,7 +51,7 @@ export default class Status { setTimeout(this._pollPing, timeout); }; - fetch('/', { method: 'GET' }) + fetch(`${parityNode}/api/ping`, { method: 'GET' }) .then((response) => dispatch(!!response.ok)) .catch(() => dispatch(false)); } diff --git a/js/src/views/Dapp/dapp.js b/js/src/views/Dapp/dapp.js index b6291d2f5..6132b200a 100644 --- a/js/src/views/Dapp/dapp.js +++ b/js/src/views/Dapp/dapp.js @@ -18,10 +18,7 @@ import React, { Component, PropTypes } from 'react'; import styles from './dapp.css'; -const hostname = `${window.location.hostname}:${window.location.port}`; -const dapphost = (hostname === 'localhost:3000') || (hostname === '127.0.0.1:3000') - ? hostname - : '127.0.0.1:8080/ui'; +const dapphost = process.env.NODE_ENV === 'production' ? 'http://127.0.0.1:8080/ui' : ''; export default class Dapp extends Component { static propTypes = { @@ -31,7 +28,7 @@ export default class Dapp extends Component { render () { const { name, type } = this.props.params; const src = type === 'global' - ? `http://${dapphost}/${name}.html` + ? `${dapphost}/${name}.html` : `http://127.0.0.1:8080/${name}/`; return ( diff --git a/js/src/views/Dapps/available.js b/js/src/views/Dapps/available.js index 3ec7df8f8..c0c2e51b3 100644 --- a/js/src/views/Dapps/available.js +++ b/js/src/views/Dapps/available.js @@ -14,6 +14,8 @@ // You should have received a copy of the GNU General Public License // along with Parity. If not, see . +import { parityNode } from '../../environment'; + const builtinApps = [ { id: '0xf9f2d620c2e08f83e45555247146c62185e4ab7cf82a4b9002a265a0d020348f', @@ -72,7 +74,7 @@ const builtinApps = [ ]; export default function () { - return fetch('http://127.0.0.1:8080/api/apps') + return fetch(`${parityNode}/api/apps`) .then((response) => { return response.ok ? response.json() @@ -84,7 +86,7 @@ export default function () { }) .then((localApps) => { return builtinApps - .concat(localApps) + .concat(localApps.filter((app) => !['ui'].includes(app.id))) .sort((a, b) => a.name.localeCompare(b.name)); }); }