Initial project setup #1

Merged
bilal.catic merged 10 commits from initial-project-setup into master 2019-05-24 14:10:17 +02:00
Showing only changes of commit 3203c63a64 - Show all commits

View File

@@ -2,9 +2,29 @@
const express = require("express");
const routes = require('./routes');
const path = require('path');
const app = express();
const port = process.env.PORT || 5000;
//Static file declaration
app.use(express.static(path.join(__dirname, 'client/build')));
//production mode
if(process.env.NODE_ENV === 'production') {
app.use(express.static(path.join(__dirname, 'client/build')));
//
app.get('*', (req, res) => {
res.sendfile(path.join(__dirname = 'client/build/index.html'));
});
}
//build mode
app.get('*', (req, res) => {
res.sendFile(path.join(__dirname+'/client/public/index.html'));
});
app.use('/api', routes);
app.listen(port, () => console.log(`App running on port ${port}!`));