Skip to content

Commit 062f09b

Browse files
committed
Handle empty video search results in API
Adds a check for empty or missing video results in the POST handler for the videos API route. Returns a user-friendly message if SearxNG returns no results, possibly due to rate-limiting, blocking, or no matches.
1 parent a690cb4 commit 062f09b

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

src/app/api/videos/route.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ interface VideoSearchBody {
2020
chatModel?: ChatModel;
2121
}
2222

23+
// Only SearxNG is used for video search. YouTube Data API is NOT used.
2324
export const POST = async (req: Request) => {
2425
try {
2526
const body: VideoSearchBody = await req.json();
@@ -72,6 +73,12 @@ export const POST = async (req: Request) => {
7273
llm,
7374
);
7475

76+
if (!videos || videos.length === 0) {
77+
return Response.json({
78+
message: 'No real-time video results found. SearxNG may be rate-limited, blocked, or the query returned no results.'
79+
}, { status: 200 });
80+
}
81+
7582
return Response.json({ videos }, { status: 200 });
7683
} catch (err) {
7784
console.error(`An error occurred while searching videos: ${err}`);

0 commit comments

Comments
 (0)