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: instrumentation.ts crypto import for webpack compatibility

diegosouzapw8caef4b6887d
diff --git a/src/instrumentation.ts b/src/instrumentation.ts
index d537bd4680..42aee252af 100644
--- a/src/instrumentation.ts
+++ b/src/instrumentation.ts
@@ -8,10 +8,12 @@
* @see https://nextjs.org/docs/app/building-your-application/optimizing/instrumentation
*/
-import crypto from "crypto";
-
function ensureJwtSecret(): void {
if (!process.env.JWT_SECRET || process.env.JWT_SECRET.trim() === "") {
+ // Use eval to hide require from webpack's static analysis
+ // This code only runs in Node.js runtime (guarded by NEXT_RUNTIME check)
+ // eslint-disable-next-line no-eval
+ const crypto = eval("require")("crypto");
const generated = crypto.randomBytes(48).toString("base64");
process.env.JWT_SECRET = generated;
console.log("[STARTUP] JWT_SECRET auto-generated (random 64-char secret)");