From 04bb7a1adae2fbd8232e647c3ba69473b8535169 Mon Sep 17 00:00:00 2001 From: mtvpls Date: Fri, 13 Feb 2026 20:08:58 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E9=89=B4=E6=9D=83=E7=9A=84m3u8?= =?UTF-8?q?=E4=BB=A3=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/api/proxy-m3u8/route.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/app/api/proxy-m3u8/route.ts b/src/app/api/proxy-m3u8/route.ts index 1c86565..6d52a03 100644 --- a/src/app/api/proxy-m3u8/route.ts +++ b/src/app/api/proxy-m3u8/route.ts @@ -35,13 +35,22 @@ export async function GET(request: Request) { } // 获取当前请求的 origin - const requestUrl = new URL(request.url); - const origin = `${requestUrl.protocol}//${requestUrl.host}`; + // 优先级:SITE_BASE 环境变量 > 从请求头构建 + let origin = process.env.SITE_BASE; + if (!origin) { + const requestUrl = new URL(request.url); + origin = `${requestUrl.protocol}//${requestUrl.host}`; + } // 获取原始 m3u8 内容 + const m3u8UrlObj = new URL(m3u8Url); const response = await fetch(m3u8Url, { headers: { - 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36', + 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36', + 'Accept': '*/*', + 'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8', + 'Accept-Encoding': 'gzip, deflate, br', + 'Referer': `${m3u8UrlObj.protocol}//${m3u8UrlObj.host}/`, }, });