From 596c9258f43c4ff7be84e59080628f5165b7d8dd Mon Sep 17 00:00:00 2001 From: Rajat Soni Date: Wed, 28 Aug 2019 23:21:35 +0530 Subject: [PATCH] accounts: update config.js --- accounts/index.js | 11 -------- accounts/src/config.js | 58 ++++++++++++++---------------------------- 2 files changed, 19 insertions(+), 50 deletions(-) diff --git a/accounts/index.js b/accounts/index.js index 7ea137a38a..60b9edd901 100755 --- a/accounts/index.js +++ b/accounts/index.js @@ -4,17 +4,6 @@ const app = express(); app.use(express.static(path.join(__dirname, 'build'))); -var env = { - TEST: 'TEST', - FYIPE_HOSTED: process.env.FYIPE_HOSTED, - HOST: process.env.HOST, - ACCOUNTS_HOST: process.env.ACCOUNTS_HOST, - BACKEND_HOST: process.env.BACKEND_HOST -} - -app.get('/env', function (req, res) { - res.send(JSON.stringify(env)); -}) app.get('/*', function (req, res) { res.sendFile(path.join(__dirname, 'build', 'index.html')); }); diff --git a/accounts/src/config.js b/accounts/src/config.js index 43063daf47..0e4481440b 100755 --- a/accounts/src/config.js +++ b/accounts/src/config.js @@ -5,55 +5,35 @@ import valid from 'card-validator'; import { isServer } from './store'; import FileSaver from 'file-saver'; import { emaildomains } from './constants/emaildomains'; -import axios from 'axios'; let apiUrl = 'http://localhost:3002'; let dashboardUrl = null; let domain = null; let adminDashboardUrl = null; -// if (!isServer) { -// if (window.location.href.indexOf('localhost') > -1) { -// apiUrl = 'http://localhost:3002'; -// dashboardUrl = 'http://localhost:3000'; -// domain = 'localhost'; -// adminDashboardUrl = 'http://localhost:3100'; -// } else if (window.location.href.indexOf('staging') > -1) { -// apiUrl = 'https://staging-api.fyipe.com'; -// dashboardUrl = 'http://staging-dashboard.fyipe.com'; -// domain = 'fyipe.com'; -// } else { -// apiUrl = 'https://api.fyipe.com'; -// dashboardUrl = 'https://dashboard.fyipe.com'; -// domain = 'fyipe.com'; -// } +if (!isServer) { + if (window.location.href.indexOf('localhost') > -1) { + apiUrl = 'http://localhost:3002'; + dashboardUrl = 'http://localhost:3000'; + domain = 'localhost'; + adminDashboardUrl = 'http://localhost:3100'; + } else if (window.location.href.indexOf('accounts:3003') > -1) { + apiUrl = 'http://backend:3002'; + dashboardUrl = 'http://dashboard:3000'; + domain = 'local'; + } else if (window.location.href.indexOf('staging') > -1) { + apiUrl = 'https://staging-api.fyipe.com'; + dashboardUrl = 'http://staging-dashboard.fyipe.com'; + domain = 'fyipe.com'; + } else { + apiUrl = 'https://api.fyipe.com'; + dashboardUrl = 'https://dashboard.fyipe.com'; + domain = 'fyipe.com'; + } -// } -function getEnvVars(){ - axios.get('http://localhost:3003/env') - .then(resp => resp.data) - .then(env => { - if (!isServer) { - if (window.location.href.indexOf('localhost') > -1) { - apiUrl = 'http://localhost:3002'; - dashboardUrl = 'http://localhost:3000'; - domain = 'localhost'; - adminDashboardUrl = 'http://localhost:3100'; - } else { - domain = 'local'; - apiUrl = env.BACKEND_HOST; - dashboardUrl = env.DASHBOARD_HOST; - } - } - }) - .catch(err => { - console.log(err) - }) } -getEnvVars(); - export const API_URL = apiUrl; export const DASHBOARD_URL = dashboardUrl;