Skip to content

Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors

fix(build): force webpack in Next.js 16 and prevent app/ routing conflicts

diegosouzapwbba7479688e3
diff --git a/package-lock.json b/package-lock.json
index 139e34a063..86659d40a2 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -20989,7 +20989,7 @@
},
"open-sse": {
"name": "@omniroute/open-sse",
- "version": "3.5.6"
+ "version": "3.5.7"
}
}
}
diff --git a/scripts/prepublish.mjs b/scripts/prepublish.mjs
index 472ca40b84..fe21666ace 100644
--- a/scripts/prepublish.mjs
+++ b/scripts/prepublish.mjs
@@ -41,6 +41,17 @@ if (existsSync(APP_DIR)) {
console.log(" 📦 Installing dependencies...");
execSync("npm install", { cwd: ROOT, stdio: "inherit" });
+// ── Step 2.5: Remove app/ directory before build ───────────
+// CRITICAL: The postinstall script may create app/node_modules/@swc/helpers/,
+// which causes Next.js 16 to interpret app/ as an App Router directory
+// (competing with src/app/). This makes the build silently skip all real
+// routes, producing a standalone with only _global-error and _not-found.
+// We MUST remove app/ before running `next build`.
+if (existsSync(APP_DIR)) {
+ console.log(" 🧹 Removing app/ created by postinstall (App Router conflict fix)...");
+ rmSync(APP_DIR, { recursive: true, force: true });
+}
+
// ── Step 3: Build Next.js ──────────────────────────────────
console.log(" 🏗️ Building Next.js (standalone)...");
execSync("npx next build", {
@@ -48,9 +59,6 @@ execSync("npx next build", {
stdio: "inherit",
env: {
...process.env,
- // Force webpack codegen — Turbopack emits hashed require() calls for
- // server external packages that break npm global installs (#394, #396, #398).
- EXPERIMENTAL_TURBOPACK: "0",
NEXT_PRIVATE_BUILD_WORKER: "0",
},
});