60 lines
1.4 KiB
JavaScript
60 lines
1.4 KiB
JavaScript
import { fileURLToPath } from "node:url";
|
|
import { dirname } from "node:path";
|
|
|
|
const projectRoot = dirname(fileURLToPath(import.meta.url));
|
|
|
|
/** @type {import('next').NextConfig} */
|
|
const nextConfig = {
|
|
output: "standalone",
|
|
serverExternalPackages: ["better-sqlite3", "sql.js", "node:sqlite", "bun:sqlite"],
|
|
turbopack: {
|
|
root: projectRoot
|
|
},
|
|
outputFileTracingRoot: projectRoot,
|
|
outputFileTracingExcludes: {
|
|
"*": ["./gitbook/**/*"]
|
|
},
|
|
images: {
|
|
unoptimized: true
|
|
},
|
|
env: {},
|
|
webpack: (config, { isServer }) => {
|
|
// Ignore fs/path modules in browser bundle
|
|
if (!isServer) {
|
|
config.resolve.fallback = {
|
|
...config.resolve.fallback,
|
|
fs: false,
|
|
path: false,
|
|
};
|
|
}
|
|
// Exclude logs, .next, gitbook subapp from watcher
|
|
config.watchOptions = { ...config.watchOptions, ignored: /[\\/](logs|\.next|gitbook)[\\/]/ };
|
|
return config;
|
|
},
|
|
async rewrites() {
|
|
return [
|
|
{
|
|
source: "/v1/v1/:path*",
|
|
destination: "/api/v1/:path*"
|
|
},
|
|
{
|
|
source: "/v1/v1",
|
|
destination: "/api/v1"
|
|
},
|
|
{
|
|
source: "/codex/:path*",
|
|
destination: "/api/v1/responses"
|
|
},
|
|
{
|
|
source: "/v1/:path*",
|
|
destination: "/api/v1/:path*"
|
|
},
|
|
{
|
|
source: "/v1",
|
|
destination: "/api/v1"
|
|
}
|
|
];
|
|
}
|
|
};
|
|
|
|
export default nextConfig;
|