-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
30 lines (24 loc) · 874 Bytes
/
app.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
const express = require("express");
const cors = require("cors");
const helmet = require("helmet");
const compression = require("compression");
const path = require("path");
const buildPath = process.env.BUILD_PATH;
const expressConfigs = require("./configs/express");
const corsConfigs = require("./configs/cors");
const helmetConfigs = require("./configs/helmet");
const app = express();
app.set("trust proxy", expressConfigs.trustProxy);
expressConfigs.enableGzip && app.use(compression());
app.use(cors(corsConfigs));
app.use(
helmet({
referrerPolicy: { policy: helmetConfigs.referrerPolicy },
contentSecurityPolicy: helmetConfigs.enableCsp && helmetConfigs.csp,
})
);
app.use(express.static(path.join(__dirname, buildPath)));
app.get("/*", function (req, res) {
res.sendFile(path.join(__dirname, buildPath, "index.html"));
});
module.exports = app;