mirror of
https://github.com/supermemoryai/supermemory.git
synced 2026-09-29 01:41:22 +00:00
fix(onboarding): hoist EXA_API_KEY check and return generic 503
Copilot review flagged two things: 1. console.error inside the handler fires on every request when the key is missing, which spams logs and can mask other errors. Moved the read to module scope so the warning fires once at module load. 2. 'Content extraction service is not configured' tells the client a bit too much about deployment state. Reply with a generic 'Content extraction is unavailable' instead, while keeping the detailed reason in the server log. Also bumped the status from 500 to 503 since 'service unavailable due to missing config' is what we are actually telling the client now.
This commit is contained in:
parent
cba67a55ed
commit
494dd25cf8
1 changed files with 9 additions and 4 deletions
|
|
@ -9,14 +9,19 @@ 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 {
|
||||
const exaApiKey = process.env.EXA_API_KEY
|
||||
if (!exaApiKey) {
|
||||
console.error("EXA_API_KEY is not configured")
|
||||
return Response.json(
|
||||
{ error: "Content extraction service is not configured" },
|
||||
{ status: 500 },
|
||||
{ error: "Content extraction is unavailable" },
|
||||
{ status: 503 },
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue