From 9efdf5259e3ffa1b0bb4e64abc76401a12de528d Mon Sep 17 00:00:00 2001 From: Kai Gritun Date: Mon, 2 Feb 2026 19:03:41 -0500 Subject: [PATCH] fix: Add SELF_HOSTING env variable to disable image optimization - Added SELF_HOSTING environment variable to control Next.js image optimization - When set to 'true', disables image optimization for self-hosted deployments - Updated next.config.ts to use unoptimized images based on SELF_HOSTING - Added SELF_HOSTING to .env.example with documentation - Updated SELF_HOSTING.md to mention new required variable - Updated env.mjs schema to validate SELF_HOSTING variable Fixes #1467 --- .env.example | 4 ++++ SELF_HOSTING.md | 1 + apps/app/next.config.ts | 3 +++ apps/app/src/env.mjs | 1 + 4 files changed, 9 insertions(+) diff --git a/.env.example b/.env.example index 227d7d00b..4daa6ef54 100644 --- a/.env.example +++ b/.env.example @@ -30,3 +30,7 @@ FIRECRAWL_API_KEY="" # For research, self-host or use cloud-version @ https://fi TRUST_APP_URL="http://localhost:3008" # Trust portal public site for NDA signing and access requests AUTH_TRUSTED_ORIGINS=http://localhost:3000,https://*.trycomp.ai,http://localhost:3002 + +# Set to 'true' when self-hosting to disable Next.js image optimization +# Required for Docker/self-hosted deployments where image optimization isn't available +SELF_HOSTING=false diff --git a/SELF_HOSTING.md b/SELF_HOSTING.md index 96c1ba4c3..ad4f6118a 100644 --- a/SELF_HOSTING.md +++ b/SELF_HOSTING.md @@ -26,6 +26,7 @@ For a functional deployment: - **Email**: `RESEND_API_KEY` in app and portal - **Workflows**: `TRIGGER_SECRET_KEY` in app - **Misc**: `REVALIDATION_SECRET`, `NEXT_PUBLIC_PORTAL_URL` in app +- **Images**: `SELF_HOSTING=true` in app (disables Next.js image optimization for self-hosted deployments) ### Prerequisites diff --git a/apps/app/next.config.ts b/apps/app/next.config.ts index ab6dc8956..4f7511e57 100644 --- a/apps/app/next.config.ts +++ b/apps/app/next.config.ts @@ -56,6 +56,9 @@ const config: NextConfig = { hostname: '**', }, ], + // Disable image optimization for self-hosted deployments + // where Next.js image optimization isn't available + unoptimized: process.env.SELF_HOSTING === 'true', }, experimental: { diff --git a/apps/app/src/env.mjs b/apps/app/src/env.mjs index 493db7973..7565602a1 100644 --- a/apps/app/src/env.mjs +++ b/apps/app/src/env.mjs @@ -46,6 +46,7 @@ export const env = createEnv({ NOVU_API_KEY: z.string().optional(), INTERNAL_API_TOKEN: z.string().optional(), STRIPE_SECRET_KEY: z.string().optional(), + SELF_HOSTING: z.string().transform((val) => val === 'true').optional().default('false'), }, client: {