Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
fix(docs): exclude referenceSource from search to fix 500 error
Sushmithamallesh committed
Jan 16, 2026 at 13:23 UTC
de950afda4198dd45c3639a5cb95933bcd7ad2a8
1 file changed
+12
-32
docs/app/api/search/route.ts
+12
-32
@@ -1,47 +1,27 @@
1
import {
2
source,
3
toolRouterSource,
4
- referenceSource,
4
examplesSource,
5
toolkitsSource,
6
} from '@/lib/source';
7
import { createSearchAPI } from 'fumadocs-core/search/server';
9
-import { NextResponse } from 'next/server';
8
11
-function getSearchIndexes() {
12
- const allPages = [
13
- ...source.getPages(),
14
- ...toolRouterSource.getPages(),
15
- ...referenceSource.getPages(),
16
- ...examplesSource.getPages(),
17
- ...toolkitsSource.getPages(),
18
- ];
9
+// Note: referenceSource excluded temporarily - it includes OpenAPI pages
10
+// that cause issues with top-level await in serverless environments
11
+const allPages = [
12
+ ...source.getPages(),
13
+ ...toolRouterSource.getPages(),
14
+ ...examplesSource.getPages(),
15
+ ...toolkitsSource.getPages(),
16
+];
17
20
- return allPages.map((page) => ({
18
+export const { GET } = createSearchAPI('advanced', {
19
+ indexes: allPages.map((page) => ({
20
id: page.url,
21
title: page.data.title ?? 'Untitled',
22
description: page.data.description,
23
url: page.url,
24
structuredData: page.data.structuredData,
25
keywords: 'keywords' in page.data ? page.data.keywords : undefined,
27
- }));
28
-}
29
-
30
-let searchHandler: ReturnType<typeof createSearchAPI>['GET'] | null = null;
31
-
32
-export async function GET(request: Request) {
33
- try {
34
- if (!searchHandler) {
35
- const indexes = getSearchIndexes();
36
- const api = createSearchAPI('advanced', { indexes });
37
- searchHandler = api.GET;
38
- }
39
- return searchHandler(request);
40
- } catch (error) {
41
- console.error('Search API error:', error);
42
- return NextResponse.json(
43
- { error: 'Search failed', message: String(error) },
44
- { status: 500 }
45
- );
46
- }
47
-}
26
+ })),
27
+});