/** * 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"; import { env } from "~/env"; const withBundleAnalyzer = require("@next/bundle-analyzer")({ enabled: process.env.ANALYZE === "true", }); async function createNextConfig(): Promise { const { createJiti } = await import("jiti"); const jiti = createJiti(fileURLToPath(import.meta.url)); await jiti.import("./src/env.ts"); return withBundleAnalyzer({ compiler: { removeConsole: false, }, experimental: { // esmExternals: "loose", // This if react-pdf gives compilation issues }, devIndicators: false, headers: async () => { return [ { headers: [ { key: "X-Frame-Options", value: "", }, ], source: "/:path*", }, ]; }, i18n: { defaultLocale: "it", locales: ["it", "en"], localeDetection: false, }, images: { unoptimized: true, minimumCacheTTL: 7200, remotePatterns: [ { hostname: "*.googleusercontent.com", pathname: "**", port: "", protocol: "https", }, { hostname: `${env.STORAGE_URL}`, }, ], }, 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, }, }); } export default (async () => await createNextConfig())();