-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
40 lines (37 loc) · 1.13 KB
/
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
35
36
37
38
39
40
const { applyMiddleware } = require("micro-middleware");
const compress = require("micro-compress");
const handler = require("serve-handler");
let server = async (req, res) => {
if (req.headers["x-forwarded-proto"] && req.headers["x-forwarded-proto"] !== "https") {
res.statusCode = 302;
res.setHeader("Location", "https://" + req.headers.host + req.url);
return res.end();
}
await handler(req, res, {
public: "./dist/",
directoryListing: false,
rewrites: [
{
source: "/",
destination: "/index.html"
}
],
headers: [
{
source: "*",
headers: [
{
key: "Strict-Transport-Security",
value: "max-age=31536000; includeSubDomains; preload"
},
{ key: "X-DNS-Prefetch-Control", value: "off" },
{ key: "X-Content-Type-Options", value: "nosniff" },
{ key: "X-Download-Options", value: "noopen" },
{ key: "X-Frame-Options", value: "SAMEORIGIN" },
{ key: "X-Xss-Protection", value: "1; mode=block" }
]
}
]
});
};
module.exports = applyMiddleware(server, [compress]);