fix(onboarding): fail fast when EXA_API_KEY is missing (#995)

This commit is contained in:
vimzh 2026-05-26 22:16:25 +05:30 committed by GitHub
parent b88de1e3b2
commit fbefac75eb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -9,8 +9,22 @@ interface ExaApiResponse {
results: ExaContentResult[]
}
const exaApiKey = process.env.EXA_API_KEY
if (!exaApiKey) {
console.error(
"EXA_API_KEY is not configured; /api/onboarding/extract-content will return 503",
)
}
export async function POST(request: Request) {
try {
if (!exaApiKey) {
return Response.json(
{ error: "Content extraction is unavailable" },
{ status: 503 },
)
}
const { urls } = await request.json()
if (!Array.isArray(urls) || urls.length === 0) {
@ -30,7 +44,7 @@ export async function POST(request: Request) {
const response = await fetch("https://api.exa.ai/contents", {
method: "POST",
headers: {
"x-api-key": process.env.EXA_API_KEY ?? "",
"x-api-key": exaApiKey,
"Content-Type": "application/json",
},
body: JSON.stringify({