From b27043b32f72cff397624e38d5bf294627973c01 Mon Sep 17 00:00:00 2001 From: "prompt.ac/@jeffrey" Date: Fri, 11 Sep 2026 10:19:23 -0400 Subject: [PATCH] /api/ask: import it the way a CommonJS file can MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The gate landed as a static `import` at the top of a file whose first line is `require("@netlify/functions")`. Mixing the two does not throw — the module simply fails to load, and lith answers "Function not found: ask" with a 404, so make, paint, translate and the prompt system went quiet rather than erroring. Dynamic `import()` inside the handler is legal in CommonJS and resolves the same module. Deployed and checked against production this time, which is what should have happened before. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01A1xZ1BonXHyds6EzF5H9Hb --- system/netlify/functions/ask.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/system/netlify/functions/ask.js b/system/netlify/functions/ask.js index b5fa40aa20..44cca2e473 100644 --- a/system/netlify/functions/ask.js +++ b/system/netlify/functions/ask.js @@ -2,8 +2,6 @@ const { stream } = require("@netlify/functions"); const dev = process.env.CONTEXT === "dev"; -import { authorize, getHandleOrEmail } from "../../backend/authorization.mjs"; - // The model a caller may reach without signing in. Anonymous traffic still // works — the front page has to demo itself to someone who has never logged in // — but it demos itself on the cheap tier. The expensive models are the thing a @@ -370,6 +368,11 @@ exports.handler = stream(async (event) => { // header — so it decides nothing about cost. This does. let handle = ""; try { + // Dynamic import because this file is CommonJS and authorization.mjs is + // not. A static `import` here loads as nothing and the route 404s. + const { authorize, getHandleOrEmail } = await import( + "../../backend/authorization.mjs" + ); const user = await Promise.race([ authorize(event.headers), new Promise((_, reject) => -- 2.51.2