-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
49 lines (44 loc) · 1.22 KB
/
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
38
39
40
41
42
43
44
45
46
47
48
49
const express = require("express");
const serveStatic = require("serve-static");
const path = require("path");
const cors = require("cors");
const app = express();
app.use(
express.urlencoded({
extended: true,
})
);
app.use(cors({ origin: true })); // enable origin cors
app.use(serveStatic(path.join(__dirname, "dist")));
app.options("*", cors());
app.use(
cors({
origin: ["*"],
credentials: true,
})
);
app.use((req, res, next) => {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Methods", "GET,PUT,PATCH,POST,DELETE");
res.header("Access-Control-Allow-Headers", "Content-Type");
app.use(cors());
next();
});
// app.use(function (req, res, next) {
// res.header("Access-Control-Allow-Origin", "*");
// res.header(
// "Access-Control-Allow-Methods",
// "GET, PUT, POST, PATCH,DELETE, OPTIONS"
// );
// res.header(
// "Access-Control-Allow-Headers",
// "Origin, X-Requested-With, Content-Type, Accept"
// );
// res.header("Access-Control-Allow-Credentials", "true");
// next();
// });
const port = process.env.PORT || 8080;
app.listen(port);
console.log(
`Message from server js on front end for heroku deploy - App is listening on port: ${port}`
);