-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
45 lines (34 loc) · 1.13 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
require('./api/config');
const express = require('express');
const compression = require('compression');
const path = require('path');
const bodyParser = require('body-parser');
const helmet = require("helmet");
const ms = require('ms');
const routes = require('./api/routes');
const app = express();
const port = process.env.PORT || 3000;
app.use(helmet());
app.use(helmet.referrerPolicy({ policy: 'same-origin' }));
// app.use(helmet.contentSecurityPolicy({
// directives: {
// defaultSrc: ["'self'"],
// scriptSrc: ["'self'", "'unsafe-eval'"],
// styleSrc: ["'self'", 'https://fonts.googleapis.com', "'unsafe-inline'"],
// imgSrc: ["'self'"],
// fontSrc: ["'self'", 'https://fonts.gstatic.com'],
// formAction: ["'self'"],
// frameAncestors: ["'none'"]
// }
// }));
app.use(compression());
app.use(bodyParser.json());
app.use(express.static(path.join(__dirname, 'dist'), {maxAge: ms('1y')}));
routes(app);
app.get('*', (req, res) => {
res.setHeader('Cache-Control', 'no-store');
res.sendFile(path.join(__dirname, 'dist/index.html'));
})
app.listen(port, () => {
console.log('API Running on Port ' + port);
});