-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
41 lines (32 loc) · 1.15 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
const express = require("express")
const helmet = require("helmet")
const getTemplate = require("./template")
const app = express()
const port = process.env.PORT || 3000
app.use(express.static('dist'))
app.use(helmet({
contentSecurityPolicy: {
directives: {
"default-src": ["'self'"]
}
}
}))
app.use((req, res, next) => {
res.set('Permissions-Policy', 'accelerometer=(), autoplay=(), battery=(), camera=(), fullscreen=(), geolocation=(), gyroscope=(), magnetometer=(), microphone=(), midi=(), notifications=(), payment=(), push=(), serial=(), speaker=(), usb=(), vibrate=(), vr=(), xr=()')
next()
})
app.get("/", async (req, res) => {
const template = await getTemplate({name: "Security test site", content: "This is the home page" })
res.send(template)
})
app.get("/about", async (req, res) => {
const template = await getTemplate({name: "About", content: "This is the about page"})
res.send(template)
})
app.get("/forms", async (req, res) => {
const template = await getTemplate({name: "Forms", content: "This is the forms page"})
res.send(template)
})
app.listen(port, () => {
console.log(`Example app listening at http://localhost:${port}`)
})