Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion apps/web/app/api/onboarding/extract-content/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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({
Expand Down