From 462a8978827e4c61a2e21b79649014c17f0b25f8 Mon Sep 17 00:00:00 2001 From: Igor Loskutov Date: Fri, 5 Sep 2025 12:59:18 -0400 Subject: [PATCH] nextjs magic --- www/app/lib/edgeConfig.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/www/app/lib/edgeConfig.ts b/www/app/lib/edgeConfig.ts index 96c94a56..685081ed 100644 --- a/www/app/lib/edgeConfig.ts +++ b/www/app/lib/edgeConfig.ts @@ -1,4 +1,5 @@ import { get } from "@vercel/edge-config"; +import { isBuildPhase } from "./next"; type EdgeConfig = { [domainWithDash: string]: { @@ -29,8 +30,12 @@ export function edgeDomainToKey(domain: string) { // get edge config server-side (prefer DomainContext when available), domain is the hostname export async function getConfig() { if (process.env.NEXT_PUBLIC_ENV === "development") { - // helps to stop nextjs build from eager loading. don't "require()" it - return (await import("../../config")).localConfig; + try { + return require("../../config").localConfig; + } catch (e) { + if (!isBuildPhase) throw new Error(e); + return require("../../config-template").localConfig; + } } const domain = new URL(process.env.NEXT_PUBLIC_SITE_URL!).hostname;