-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathnext.config.ts
More file actions
66 lines (57 loc) · 2.01 KB
/
next.config.ts
File metadata and controls
66 lines (57 loc) · 2.01 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
import type { NextConfig } from "next";
import createNextIntlPlugin from "next-intl/plugin";
import {
assessDistDirLocking,
resolveNextBuildDir,
} from "./src/lib/dev/project-filesystem";
const withNextIntl = createNextIntlPlugin("./src/i18n/request.ts");
const projectDir = __dirname;
const resolvedBuildDir = resolveNextBuildDir(projectDir, process.env.NEXT_BUILD_DIR);
const distDirLocking = assessDistDirLocking(projectDir, resolvedBuildDir.distDir);
if (resolvedBuildDir.warning) {
console.warn(`[next.config] ${resolvedBuildDir.warning}`);
}
if (distDirLocking.disableLock) {
const mountPoint = distDirLocking.mount?.mountPoint ?? projectDir;
console.warn(
`[next.config] Detected ${distDirLocking.reason} at ${mountPoint}; disabling Next dist-dir locking so dev/build can run on this mount. SQLite should still use a local DATABASE_URL on network filesystems.`
);
}
const securityHeaders = [
{ key: "X-Content-Type-Options", value: "nosniff" },
{ key: "X-Frame-Options", value: "SAMEORIGIN" },
{ key: "Referrer-Policy", value: "strict-origin-when-cross-origin" },
{ key: "Permissions-Policy", value: "camera=(), microphone=(), geolocation=()" },
];
const serverExternalPackages = [
"better-sqlite3",
"pdf-parse",
// Turbopack on Windows can panic while creating the junction for this scoped package.
...(process.platform === "win32" ? [] : ["@larksuiteoapi/node-sdk"]),
];
const nextConfig: NextConfig = {
output: "standalone",
serverExternalPackages,
// Keep distDir inside the project root so Turbopack accepts it.
...(resolvedBuildDir.distDir ? { distDir: resolvedBuildDir.distDir } : {}),
...(distDirLocking.disableLock
? {
experimental: {
lockDistDir: false,
},
}
: {}),
turbopack: {
// Set the project root explicitly to avoid lockfile detection issues.
root: projectDir,
},
async headers() {
return [
{
source: "/(.*)",
headers: securityHeaders,
},
];
},
};
export default withNextIntl(nextConfig);