-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
32 lines (28 loc) · 801 Bytes
/
index.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
const express = require("express");
const cors = require("cors");
const path = require("path");
const sendGrid = require("@sendgrid/mail");
const app = express();
app.use(express.json());
app.use(cors());
// Serve static files from the React app
app.use(express.static(path.join(__dirname, "client/build")));
// a
// app.use((req, res, next) => {
// res.setHeader("Access-Control-Allow-Origin", "*");
// res.setHeader(
// "Access-Control-Allow-Methods",
// "GET, POST, PUT, PATCH, DELETE"
// );
// next();
// });
require("./routes")(app);
app.get("*", (req, res) => {
res.sendFile(path.join(__dirname + "/client/build/index.html"));
});
const server = app.listen(process.env.PORT || 5000, () => {
console.log("Server running on port", 5000);
});
module.exports = {
server
};