Created
February 7, 2022 12:32
-
-
Save alperbayram/3214a23d1a406d6838d70970526ccaf8 to your computer and use it in GitHub Desktop.
one
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 ContactRoute = require("./Routes/ContactRoute"); | |
const app = express(); | |
//middleware | |
app.use(express.static(path.resolve(__dirname, "../client/build"))); | |
app.use(express.json()); | |
app.use(express.urlencoded({ extended: true })); | |
//routes | |
app.use("/", ContactRoute); | |
app.get("*", (req, res) => { | |
res.sendFile(path.resolve(__dirname, "../client/build", "index.html")); | |
}); | |
//connect port | |
const port = process.env.PORT || 3001; | |
app.listen(port, () => { | |
console.log(`Server listening on ${port}`); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment