-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
37 lines (32 loc) · 895 Bytes
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/**
* Module dependencies.
*/
const path = require("path");
const express = require("express");
const dotenv = require("dotenv");
/**
* Create Express server.
*/
const app = express();
/**
* Load environment variables from .env file.
* if there is a variable in the .env file which collides with one that already
* exists in your environment, then that variable will be skipped
*/
dotenv.config();
const port = process.env.PORT;
/**
* Express configuration.
*/
app.use(express.static(path.join(__dirname, "dist")));
// Redirect all of your server requests to /index.html (client-side router (react router) handles routing)
app.get("/*", function(req, res) {
res.sendFile(__dirname + "/dist/index.html");
});
app.listen(
port,
error =>
error
? console.log(error)
: console.log(`Streamlo Frontend Application Server Initialized. Listening on port ${port}`)
);