-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmiddleware.ts
45 lines (42 loc) · 1.53 KB
/
middleware.ts
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
import * as nosecone from "@nosecone/next";
const noseconeConfig: nosecone.NoseconeOptions = {
...nosecone.defaults,
contentSecurityPolicy: {
...nosecone.defaults.contentSecurityPolicy,
directives: {
...nosecone.defaults.contentSecurityPolicy.directives,
imgSrc: [
...nosecone.defaults.contentSecurityPolicy.directives.imgSrc,
"https://vercel.com", // Deploy button
"https://www.netlify.com", // Deploy button
],
scriptSrc: [
// We have to use unsafe-inline because next-themes and Vercel Analytics
// do not support nonce
// https://github.com/pacocoursey/next-themes/issues/106
// https://github.com/vercel/analytics/issues/122
//...nosecone.defaults.contentSecurityPolicy.directives.scriptSrc,
"'self'",
"'unsafe-inline'",
"'unsafe-eval'",
"https://plausible.io", // Analytics
],
connectSrc: [
...nosecone.defaults.contentSecurityPolicy.directives.connectSrc,
"https://plausible.io", // Analytics
],
// We only set this in production because the server may be started
// without HTTPS
upgradeInsecureRequests: process.env.NODE_ENV === "production",
},
},
crossOriginEmbedderPolicy: {
policy: "credentialless", // Allows embedding the deploy buttons
},
} as const;
const noseconeMiddleware = nosecone.createMiddleware(
process.env.VERCEL_ENV === "preview"
? nosecone.withVercelToolbar(noseconeConfig)
: noseconeConfig,
);
export default noseconeMiddleware;