-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
41 lines (34 loc) · 1.04 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
const express = require('express');
const path = require("path");
const cookieParser = require('cookie-parser');
const bodyParser = require('body-parser');
const router = require('./api')
const cors = require('cors');
const app = express();
const port = 8080;
app.use(express.static(path.join(__dirname, "..", "client/build")));
app.use(express.static("client/build"));
app.use(cookieParser());
app.use(bodyParser.json());
app.use(cors({
credentials: true,
// origin: 'https://reminder-app-ad.fly.dev',
orogin: 'localhost:8080'
}));
app.use(function(req, res, next) {
res.header('Content-Type', 'application/json;charset=UTF-8')
res.header('Access-Control-Allow-Credentials', true)
res.header(
'Access-Control-Allow-Headers',
'Origin, X-Requested-With, Content-Type, Accept'
)
next()
})
app.use('/api', router);
// app.listen(port, '0.0.0.0', () => {
// console.log(`Example app listening on port ${port}`)
// })
const server = app.listen(port, () => {
console.log(`Example app listening on port ${port}`)
});
module.exports = server;