jev-8ball/functions/api/status.js
oiupoyt 4826b9c2b5 fix: remove the hardcoded OpenRouter key and always-true hasKey reporting
The key was committed to three backends behind `|| DEFAULT_KEY` fallbacks, which
also meant a misconfigured deploy silently billed the bundled key instead of
failing. It is now read from the environment only: /api/ask answers 503 and
/api/status reports hasKey:false when it is absent.

hasKey was unreachable-false as well, via `|| true` in the Pages function and
`|| DEFAULT_KEY` in the worker, so it could never signal a missing key.

All responses now go through a shared json() helper, so error paths carry the
same CORS headers and content type as success paths, and wrangler.json declares
the ASSETS binding the worker's static fallback already referenced.
2026-09-20 01:47:51 +05:30

15 lines
399 B
JavaScript

export async function onRequestGet(context) {
const { env } = context;
return new Response(JSON.stringify({
status: "online",
model: "typesafe/jev-1.13",
engine: "TypeSafe Jev (Cloudflare Pages Edge)",
hasKey: Boolean(env.OPENROUTER_API_KEY)
}), {
status: 200,
headers: {
"Content-Type": "application/json",
"Access-Control-Allow-Origin": "*"
}
});
}