File size: 914 Bytes
5c0175e | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | // GET /api/offcloud/debug — diagnostic endpoint to verify API key is being read.
// Returns the key detection status without exposing the key itself.
// Use this to troubleshoot "stuck in mock mode" issues.
import { NextResponse } from "next/server";
import { getApiKey, testConnection } from "@/lib/offcloud";
export const dynamic = "force-dynamic";
export async function GET() {
const key = await getApiKey();
const keySource = process.env.OFFCLOUD_API_KEY && process.env.OFFCLOUD_API_KEY.trim()
? "env_var (HF Space Secret)"
: key
? "settings_table (set via UI)"
: "none";
const conn = await testConnection();
return NextResponse.json({
keyDetected: !!key,
keyLength: key?.length ?? 0,
keyPrefix: key ? `${key.slice(0, 4)}...${key.slice(-4)}` : null,
keySource,
connection: conn,
timestamp: new Date().toISOString(),
});
}
|