-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
34 lines (26 loc) · 956 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
33
34
const express = require("express");
const app = express();
const dotenv=require("dotenv");
const path = require("path");
//const a2ojRoute=require("./routes/a2oj");
const laddersRoute=require("./routes/ladders");
const loginRoute=require("./routes/login");
const updateSubRoute=require("./routes/updateSub");
dotenv.config();
app.use(express.json());
app.use((req, res, next) => {
res.header('Access-Control-Allow-Origin', '*');
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
next();
});
app.use("/api/ladders",laddersRoute);
app.use("/api/login",loginRoute);
app.use("/api/updatesub",updateSubRoute);
//app.use("/api/a2oj",a2ojRoute);
app.use(express.static(path.join(__dirname, "/client/build")));
app.get('*', (req, res) => {
res.sendFile(path.join(__dirname, '/client/build', 'index.html'));
});
app.listen(process.env.PORT||5000, () => {
console.log("backend is running");
});