From a4a982aed721ea9d1d0635b51817d29bb311e847 Mon Sep 17 00:00:00 2001 From: chris Date: Sun, 24 May 2026 20:25:17 -0400 Subject: [PATCH] =?UTF-8?q?Fix=20/api/prompts/test=20=E2=80=94=20move=20be?= =?UTF-8?q?fore=20auth=20middleware=20so=20it's=20accessible=20without=20a?= =?UTF-8?q?=20login?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Sonnet 4.6 --- server/routes/prompts.js | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/server/routes/prompts.js b/server/routes/prompts.js index 06180fc..c2bccc7 100644 --- a/server/routes/prompts.js +++ b/server/routes/prompts.js @@ -202,20 +202,8 @@ async function callOllama() { // ── Router ─────────────────────────────────────────────────────────────── const router = Router() -router.use(auth) -router.get('/', async (req, res) => { - try { - const prompt = await callOllama() - console.log(`[prompts] Ollama OK — "${prompt.slice(0, 60)}…"`) - res.json({ prompt, source: 'ollama', model: OLLAMA_MODEL }) - } catch (err) { - console.error(`[prompts] Ollama failed, using built-in fallback. Reason: ${err.message}`) - res.json({ prompt: nextFallback(), source: 'local' }) - } -}) - -// ── Debug endpoint — hit /api/prompts/test to see exactly what Ollama returns +// Debug endpoint — no auth needed, only exposes connection status router.get('/test', async (req, res) => { const result = { url: `${OLLAMA_URL}/api/generate`, model: OLLAMA_MODEL } try { @@ -229,4 +217,17 @@ router.get('/test', async (req, res) => { res.json(result) }) +router.use(auth) + +router.get('/', async (req, res) => { + try { + const prompt = await callOllama() + console.log(`[prompts] Ollama OK — "${prompt.slice(0, 60)}…"`) + res.json({ prompt, source: 'ollama', model: OLLAMA_MODEL }) + } catch (err) { + console.error(`[prompts] Ollama failed, using built-in fallback. Reason: ${err.message}`) + res.json({ prompt: nextFallback(), source: 'local' }) + } +}) + export default router