-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathproxy.ts
More file actions
44 lines (42 loc) · 1.52 KB
/
proxy.ts
File metadata and controls
44 lines (42 loc) · 1.52 KB
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
import { isDevelopment } from "@arcjet/env";
import * as nosecone from "@nosecone/next";
const noseconeConfig: nosecone.Options = {
...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: !isDevelopment(process.env),
},
},
crossOriginEmbedderPolicy: {
policy: "credentialless", // Allows embedding the deploy buttons
},
} as const;
export const proxy = nosecone.createMiddleware(
process.env.VERCEL_ENV === "preview"
? nosecone.withVercelToolbar(noseconeConfig)
: noseconeConfig,
);