Repository navigation
Expand file tree
/
Copy pathnext.config.ts
More file actions
110 lines (106 loc) · 3.57 KB
/
Copy pathnext.config.ts
File metadata and controls
110 lines (106 loc) · 3.57 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
import type { NextConfig } from "next";
import { readFileSync } from "fs";
import { dirname, join } from "path";
import { fileURLToPath } from "url";
const configDir = dirname(fileURLToPath(import.meta.url));
const { version } = JSON.parse(readFileSync(join(configDir, "package.json"), "utf8")) as { version: string };
let piVersion = "unknown";
try {
const piPkgPath = join(configDir, "node_modules/@earendil-works/pi-coding-agent/package.json");
piVersion = (JSON.parse(readFileSync(piPkgPath, "utf8")) as { version: string }).version;
} catch { /* package not found, use default */ }
// mdast-util-gfm-autolink-literal (remark-gfm) ships a RegExp lookbehind that
// Safari parses only from 16.4, which blanked `/` on iOS 16.2 (#753). The loader
// swaps it for an equivalent built at runtime; both bundlers must run it.
const gfmAutolinkEmailLoader = join(configDir, "lib/gfm-autolink-email-loader.cjs");
const nextConfig: NextConfig = {
outputFileTracingRoot: configDir,
experimental: {
// proxy.ts matches /api/:path*, and Next buffers the request body whenever
// a proxy is present, capped at 10 MB by default. The upload route accepts
// up to 100 MB per request, so raise the buffer above that or large uploads
// are truncated and fail with "Failed to parse body as FormData."
proxyClientMaxBodySize: "128mb",
},
// next/image is only used for the static logo, so the /_next/image optimizer
// (and its sharp/libheif attack surface, see GHSA-2xp9-vwfh-vxw4) is not needed.
images: { unoptimized: true },
// `next dev` runs Turbopack and `npm run build` runs webpack.
turbopack: {
rules: {
"**/mdast-util-gfm-autolink-literal/lib/index.js": { loaders: [gfmAutolinkEmailLoader] },
},
},
webpack(config) {
config.module.rules.push({
test: /[\\/]mdast-util-gfm-autolink-literal[\\/]lib[\\/]index\.js$/,
loader: gfmAutolinkEmailLoader,
});
return config;
},
// Node modules keep the syntax they ship unless listed here, and mermaid's
// lazy diagram chunks are full of class `static {}` blocks (#753).
transpilePackages: ["mermaid", "@mermaid-js/parser"],
serverExternalPackages: [
"node-pty",
"undici",
"web-push",
"@earendil-works/pi-coding-agent",
"@earendil-works/pi-agent-core",
"@earendil-works/pi-ai",
"@earendil-works/pi-tui",
],
// Next 16 blocks cross-origin access to dev resources by default. Allow the
// loopback and the RFC1918 LAN ranges so the dev server stays reachable
// from other machines on the same LAN.
allowedDevOrigins: [
"127.0.0.1",
"10.*.*.*",
// 172.16.0.0/12
"172.16.*.*",
"172.17.*.*",
"172.18.*.*",
"172.19.*.*",
"172.20.*.*",
"172.21.*.*",
"172.22.*.*",
"172.23.*.*",
"172.24.*.*",
"172.25.*.*",
"172.26.*.*",
"172.27.*.*",
"172.28.*.*",
"172.29.*.*",
"172.30.*.*",
"172.31.*.*",
"192.168.*.*",
],
async headers() {
return [
{
source: "/",
headers: [
{ key: "Cache-Control", value: "private, no-cache, max-age=0, must-revalidate" },
],
},
{
source: "/sw.js",
headers: [
{ key: "Cache-Control", value: "public, max-age=0, must-revalidate" },
{ key: "Service-Worker-Allowed", value: "/" },
],
},
{
source: "/manifest.webmanifest",
headers: [
{ key: "Cache-Control", value: "public, max-age=0, must-revalidate" },
],
},
];
},
env: {
NEXT_PUBLIC_APP_VERSION: version,
NEXT_PUBLIC_PI_VERSION: piVersion,
},
};
export default nextConfig;