Files
old-psihologija/server.js

29 lines
662 B
JavaScript
Raw Normal View History

2019-05-23 16:41:50 +02:00
'use strict';
const express = require("express");
2019-05-23 19:33:37 +02:00
const path = require('path');
2019-05-24 10:14:41 +02:00
const routes = require('./routes');
2019-05-23 16:41:50 +02:00
const app = express();
const port = process.env.PORT || 5000;
2019-05-23 19:33:37 +02:00
2019-05-24 10:14:41 +02:00
app.use('/api', routes);
2019-05-23 19:33:37 +02:00
//Static file declaration
app.use(express.static(path.join(__dirname, 'client/build')));
//production mode
if(process.env.NODE_ENV === 'production') {
app.get('*', (req, res) => {
res.sendfile(path.join(__dirname = 'client/build/index.html'));
});
}
//build mode
app.get('*', (req, res) => {
2019-05-24 10:14:41 +02:00
res.sendFile(path.join(__dirname + '/client/public/index.html'));
2019-05-23 19:33:37 +02:00
});
2019-05-23 16:41:50 +02:00
app.listen(port, () => console.log(`App running on port ${port}!`));