Skip to content

Commit

Permalink
add-basic-server-for-heroku
Browse files Browse the repository at this point in the history
relates #10
  • Loading branch information
ali-7 committed Apr 15, 2019
1 parent 3d696e3 commit b04e4d3
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions server/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const path = require("path");
const express = require("express");
const favicon = require("express-favicon");

const app = express();

if (process.env.NODE_ENV === "production") {
app.use(favicon(path.join(__dirname, "..", "client", "build/favicon.ico")));

app.use(express.static(path.join(__dirname, "..", "client", "build")));

app.get("*", (req, res) => {
res.sendFile(path.join(__dirname, "..", "client", "build", "index.html"));
});
}

app.get("/test-server", (req, res) => {
res.json({ server: "check" });
});

const port = process.env.PORT || 5000;

app.listen(port, () => console.log(`App listen on port ${port}`));

0 comments on commit b04e4d3

Please sign in to comment.