Production (Docker): src/lib/db.ts now uses bun:sqlite + drizzle-orm/bun-sqlite. No native addon compilation needed — bun:sqlite is a Bun built-in. The Dockerfile drops all native build tools (python3, make, g++) and uses --ignore-scripts. Tests (Vitest/Node.js): bun:sqlite is unavailable under Node.js, so: - tests/helpers/db.ts keeps better-sqlite3 + drizzle-orm/better-sqlite3 for integration tests that need a real in-memory SQLite - vitest.config.ts aliases bun:sqlite → a thin better-sqlite3 shim and drizzle-orm/bun-sqlite → drizzle-orm/better-sqlite3 for unit tests that transitively import src/lib/db.ts without executing any queries - better-sqlite3 stays as a devDependency (test-only, not built in Docker) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
47 lines
1.6 KiB
JavaScript
47 lines
1.6 KiB
JavaScript
/* global process */
|
|
|
|
/** @type {import('next').NextConfig} */
|
|
const nextConfig = {
|
|
serverExternalPackages: ['bun:sqlite'],
|
|
experimental: {
|
|
serverActions: {
|
|
bodySizeLimit: '2mb'
|
|
}
|
|
},
|
|
output: 'standalone',
|
|
async headers() {
|
|
const isDev = process.env.NODE_ENV === "development";
|
|
return [
|
|
{
|
|
// Applied to all routes; API routes get no-op CSP but benefit from other headers
|
|
source: "/(.*)",
|
|
headers: [
|
|
{ key: "X-Content-Type-Options", value: "nosniff" },
|
|
// X-Frame-Options kept for legacy browsers that don't support frame-ancestors CSP directive
|
|
{ key: "X-Frame-Options", value: "DENY" },
|
|
{ key: "Referrer-Policy", value: "strict-origin-when-cross-origin" },
|
|
{ key: "Permissions-Policy", value: "camera=(), microphone=(), geolocation=(), interest-cohort=()" },
|
|
{
|
|
key: "Content-Security-Policy",
|
|
value: [
|
|
"default-src 'self'",
|
|
// unsafe-eval/unsafe-inline required only for Next.js HMR in development
|
|
isDev
|
|
? "script-src 'self' 'unsafe-inline' 'unsafe-eval'"
|
|
: "script-src 'self' 'unsafe-inline'",
|
|
"style-src 'self' 'unsafe-inline' https://fonts.googleapis.com",
|
|
"font-src 'self' https://fonts.gstatic.com",
|
|
"img-src 'self' data: blob:",
|
|
"worker-src blob:",
|
|
"connect-src 'self'",
|
|
"frame-ancestors 'none'",
|
|
].join("; "),
|
|
},
|
|
],
|
|
},
|
|
];
|
|
},
|
|
};
|
|
|
|
export default nextConfig;
|