infoalloggi-monorepo/apps/infoalloggi/next.config.ts

74 lines
1.8 KiB
TypeScript
Raw Normal View History

/**
* Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation.
* This is especially useful for Docker builds.
*/
import { fileURLToPath } from "node:url";
import type { NextConfig } from "next";
2025-10-23 15:16:42 +02:00
import { env } from "~/env";
const withBundleAnalyzer = require("@next/bundle-analyzer")({
enabled: process.env.ANALYZE === "true",
});
async function createNextConfig(): Promise<NextConfig> {
const { createJiti } = await import("jiti");
const jiti = createJiti(fileURLToPath(import.meta.url));
await jiti.import("./src/env.ts");
const configs: NextConfig = {
compiler: {
removeConsole: false,
},
experimental: {
scrollRestoration: true,
2026-05-19 18:42:34 +02:00
proxyClientMaxBodySize: "300mb",
// esmExternals: "loose", // This if react-pdf gives compilation issues
},
allowedDevOrigins: ["host.docker.internal"],
devIndicators: false,
2026-05-19 18:42:34 +02:00
// headers: async () => {
// return [
// {
// source: "/api/trpc/:path*",
// headers: [
// // {
// // key: "Cache-Control",
// // value:
// // "no-cache, no-store, must-revalidate, max-age=0, proxy-revalidate",
// // },
// ],
// },
// ];
// },
i18n: {
defaultLocale: "it",
locales: ["it", "en"],
localeDetection: false,
},
images: {
unoptimized: true,
minimumCacheTTL: 7200,
},
output: env.NODE_ENV === "production" ? "standalone" : undefined, // This is for docker builds
transpilePackages: ["@t3-oss/env-nextjs", "@t3-oss/env-core"],
reactStrictMode: true,
rewrites: async () => {
return [
{
destination: env.NODE_ENV === "production" ? "/404" : "/api/panel",
source: "/api/panel",
},
];
},
typescript: {
ignoreBuildErrors: true,
},
};
return withBundleAnalyzer(configs);
}
export default (async () => await createNextConfig())();