forked from akai/readest
@@ -113,7 +113,7 @@ async function handleRequest(request: NextRequest, method: 'GET' | 'HEAD') {
|
||||
});
|
||||
}
|
||||
|
||||
if (stream === 'true' || (contentLength && parseInt(contentLength) > 1024 * 1024)) {
|
||||
if (stream === 'true' && contentLength && parseInt(contentLength) > 1024 * 1024) {
|
||||
console.log(`[OPDS Proxy] Streaming: ${url}`);
|
||||
|
||||
return new NextResponse(response.body, {
|
||||
@@ -129,13 +129,15 @@ async function handleRequest(request: NextRequest, method: 'GET' | 'HEAD') {
|
||||
},
|
||||
});
|
||||
} else {
|
||||
const data = await response.text();
|
||||
console.log(`[OPDS Proxy] Success: ${url} (${data.length} bytes)`);
|
||||
const buf = await response.arrayBuffer();
|
||||
const length = buf.byteLength;
|
||||
console.log(`[OPDS Proxy] Success: ${url} (${length} bytes)`);
|
||||
|
||||
return new NextResponse(data, {
|
||||
return new NextResponse(buf, {
|
||||
status: 200,
|
||||
headers: {
|
||||
'Content-Type': contentType,
|
||||
'Content-Length': length.toString(),
|
||||
'Cache-Control': 'public, max-age=300',
|
||||
'Access-Control-Allow-Origin': '*',
|
||||
'Access-Control-Allow-Methods': 'GET, HEAD, OPTIONS',
|
||||
|
||||
Reference in New Issue
Block a user