-
Notifications
You must be signed in to change notification settings - Fork 2
/
server.js
46 lines (41 loc) · 1.38 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
44
45
const compression = require('compression');
const cors = require('cors');
const express = require('express');
const helmet = require('helmet');
const app = express();
app.use(compression());
app.use(cors({ origin: 'https://trello.com' }));
app.use(helmet.contentSecurityPolicy({
useDefaults: false,
directives: {
defaultSrc: ["'self'"],
scriptSrc: ["'self'", "https://*.trellocdn.com", "https://*.trello.com", "https://cdn.skypack.dev https://esm.sh", "https://*.fontawesome.com"],
imgSrc: ["*"],
fontSrc: ["*"],
styleSrc: ["'self'", "'unsafe-inline'", "https://*.trello.com", "https://fonts.googleapis.com", "https://*.fontawesome.com"],
frameSrc: ["'self'"],
connectSrc: ["'self'", "https://*.fontawesome.com"],
objectSrc: ["'none'"],
},
}));
app.use(helmet.hsts({
maxAge: 63072000,
preload: true,
}));
app.use(helmet.originAgentCluster());
app.use(helmet.noSniff());
app.use(helmet.referrerPolicy());
app.use((req, res, next) => {
res.setHeader(
"Permissions-Policy",
'geolocation=(self "https://trello.com/"), microphone=()'
);
next();
});
app.use(express.static('public'));
app.use(express.urlencoded({ extended: true }));
app.use(express.json());
const listener = app.listen(process.env.PORT, function () {
console.info(`Node Version: ${process.version}`);
console.log('Trello Power-Up Server listening on port ' + listener.address().port);
});