Skip to content

Commit a4a47b0

Browse files
authored
Merge pull request #287 from dedis/setup-env-variable
feat: use env variables to configure setup
2 parents e03dd72 + da59041 commit a4a47b0

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

web/backend/config.env.template

+7-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ FRONT_END_URL="https://dvoting-dev.dedis.ch:3000"
66
# Proxy address of the default proxy
77
DELA_NODE_URL="http://localhost:9081"
88

9+
# Backend server
10+
BACKEND_HOST="localhost"
11+
BACKEND_PORT="5000"
12+
913
# Secret used to create secure sessions
1014
SESSION_SECRET="session secret"
1115

@@ -17,4 +21,6 @@ PRIVATE_KEY="28912721dfd507e198b31602fb67824856eb5a674c021d49fdccbe52f0234409"
1721
DB_PATH="./"
1822
# Database credentials
1923
DATABASE_USERNAME = "dvoting"
20-
DATABASE_PASSWORD = "dvoting"
24+
DATABASE_PASSWORD = "dvoting"
25+
DATABASE_PORT = 5432
26+
DATABASE_HOST = "localhost"

web/backend/src/Server.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ let enf: Enforcer;
4848
async function initEnf() {
4949
const a = await SequelizeAdapter.newAdapter({
5050
dialect: 'postgres',
51-
host: 'localhost',
52-
port: 5432,
51+
host: process.env.DATABASE_HOST,
52+
port: parseInt(process.env.DATABASE_PORT || '5432', 10),
5353
username: process.env.DATABASE_USERNAME,
5454
password: process.env.DATABASE_PASSWORD,
5555
database: 'casbin',

web/frontend/src/setupProxy.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const { createProxyMiddleware } = require('http-proxy-middleware');
33
module.exports = function (app) {
44
app.use(
55
createProxyMiddleware('/api', {
6-
target: 'http://localhost:5000',
6+
target: `http://${process.env.BACKEND_HOST}:${process.env.BACKEND_PORT}`,
77
changeOrigin: true,
88
headers: {
99
Connection: 'keep-alive',

0 commit comments

Comments
 (0)