feat: Enhance proxy to forward client headers and control caching, and simplify video player's source handling by removing internal proxy URL construction.

This commit is contained in:
kuekhaoyang
2025-11-29 16:19:48 +08:00
parent a5c76b6f32
commit d7b2d373ea
4 changed files with 23 additions and 24 deletions
+11 -1
View File
@@ -15,7 +15,16 @@ export async function GET(request: NextRequest) {
}
try {
const response = await fetchWithRetry({ url, request });
// Extract headers to forward (Cookies, Accept-Language, etc.)
const requestHeaders: Record<string, string> = {};
const forwardHeaders = ['cookie', 'accept', 'accept-language'];
forwardHeaders.forEach(key => {
const value = request.headers.get(key);
if (value) requestHeaders[key] = value;
});
const response = await fetchWithRetry({ url, request, headers: requestHeaders });
const contentType = response.headers.get('Content-Type');
@@ -68,6 +77,7 @@ export async function GET(request: NextRequest) {
headers.set('Access-Control-Allow-Origin', '*');
headers.set('Access-Control-Allow-Methods', 'GET, OPTIONS');
headers.set('Access-Control-Allow-Headers', 'Content-Type, Authorization');
headers.set('Cache-Control', 'no-store, no-cache, must-revalidate, proxy-revalidate');
return new NextResponse(response.body, {
status: response.status,