added env var for accounts

This commit is contained in:
Rajat Soni
2019-08-28 15:46:14 +05:30
parent 12ccbbae33
commit 9f53e04be9
3 changed files with 36 additions and 16 deletions

View File

@@ -4,7 +4,18 @@ const app = express();
app.use(express.static(path.join(__dirname, 'build')));
app.get('/*', function(req, res) {
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'));
});

View File

@@ -29,20 +29,29 @@ 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 {
apiUrl = 'http://backend:3002';
dashboardUrl = 'http://dashboard:3000';
domain = 'local';
}
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;

View File

@@ -82,11 +82,11 @@ spec:
- name: FYIPE_HOSTED
value: "true"
- name: HOST
value: "accounts"
value: "accounts:3003"
- name: BACKEND_HOST
value: "backend"
value: "backend:3002"
- name: DASHBOARD_HOST
value: "dashboard"
value: "dashboard:3000"
ports:
- containerPort: 3003
hostPort: 3003