feat(opds): add support to search in OPDS, closes #2598 (#2634)

This commit is contained in:
Huang Xin
2025-12-06 19:13:45 +08:00
committed by GitHub
parent b78466ca93
commit 00f36af03a
37 changed files with 404 additions and 64 deletions
@@ -33,7 +33,7 @@ async function handleRequest(request: NextRequest, method: 'GET' | 'HEAD') {
console.log(`[OPDS Proxy] ${method}: ${url}`);
const controller = new AbortController();
const timeout = setTimeout(() => controller.abort(), 10000);
const timeout = setTimeout(() => controller.abort(), 20000);
const headers: HeadersInit = {
'User-Agent': 'Readest/1.0 (OPDS Browser)',
Accept: 'application/atom+xml, application/xml, text/xml, application/json, */*',
@@ -82,7 +82,16 @@ async function handleRequest(request: NextRequest, method: 'GET' | 'HEAD') {
},
});
}
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
return new NextResponse(data, {
status: response.status,
headers: {
...Object.fromEntries(response.headers.entries()),
'Cache-Control': 'public, max-age=300',
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'GET, HEAD, OPTIONS',
'Access-Control-Allow-Headers': 'Content-Type',
},
});
}
const contentType = response.headers.get('Content-Type') || 'text/xml';