-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
34 lines (25 loc) · 928 Bytes
/
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
const express = require('express');
// const bodyParser = require('body-parser');
const path = require('path');
const cors = require('cors');
const api = require('./server/routes/api');
// const port=3000;
const port = process.env.PORT || 1000;
const app = express();
app.use(cors());
app.use(function (req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
res.header("Access-Control-Allow-Methods", "POST, GET, PUT, DELETE, OPTIONS");
next();
});
// app.use(express.static(path.join(__dirname, 'dist')));
app.use(express.urlencoded({ extended: true }));
app.use(express.json());
app.use('/api', api);
// app.get('*', (req, res) => {
// res.sendFile(path.join(__dirname, 'dist/index.html'));
// });
app.listen(port, function () {
console.log("Server running on localhost:" + port);
});