Skip to content

Commit 48f7914

Browse files
committed
adding environment variables handling for server database connection
1 parent 7caad2b commit 48f7914

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/server.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,15 @@ import 'babel-polyfill';
55
import path from 'path';
66
import mongoose from 'mongoose';
77

8-
98
const config = require('./config/main.json');
109
const port = (!global.process.env.PORT) ? 1234 : global.process.env.PORT;
1110
const server = global.server = express();
1211

13-
mongoose.connect(config.mongoDB);
12+
if (process.env.NODE_ENV === "production") {
13+
mongoose.connect(process.env.DATABASE_URL);
14+
} else {
15+
mongoose.connect(config.mongoDB);
16+
}
1417

1518
server.set('port', port);
1619
server.use(express.static(path.join(__dirname, 'public')));

0 commit comments

Comments
 (0)