Created
August 9, 2020 17:18
-
-
Save rajputankit22/31bfefd8182b362359404a6a56b7f5da to your computer and use it in GitHub Desktop.
server.js file code for deploy a react app to node server.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require("express"); | |
const path = require("path"); | |
const app = express(); | |
app.use(express.static(path.join(__dirname, "build"))); | |
app.post("/", function (req, res) { | |
res.sendFile(path.join(__dirname, "build", "index.html")); | |
}); | |
app.get("/*", function (req, res) { | |
res.sendFile(path.join(__dirname, "build", "index.html")); | |
}); | |
app.listen(process.env.PORT || 3000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment