**Web接口反馈的完整内容
{
"result": {
"created_on": "2026-04-15T15:30:39.649278Z",
"modified_on": "2026-04-15T15:30:39.649278Z",
"id": "redirect",
"tag": "9f7553a9ee694d759bb3db224b81450e",
"entry_point": "// ===========================================\n// Cloudflare Workers 智能重定向脚本\n// 配合 Lucky STUN 穿透实现 IPv4/IPv6 自动分流\n// \n// 使用说明:\n// 1. 将下方 CONFIG 中的 '123.xyz' 替换为你的主域名\n// 2. 确保 WebHook 能自动更新 v4.port 的值\n// 3. 部署到 Cloudflare Workers\n// ===========================================\n\nconst CONFIG = {\n domain: '1340839.xyz', // 请替换为你的主域名\n v4: {\n target: 'ipv4.1340839.xyz', // IPv4 目标域名(需替换)\n port: Number(6666) || 80 // 由 WebHook 自动更新\n },\n v6: {\n target: 'ipv6.1340839.xyz', // IPv6 目标域名(需替换)\n port: 38989 // IPv6 固定端口\n }\n};\n\naddEventListener('fetch', event =\u003e {\n event.respondWith(handleRequest(event.request));\n});\n\nasync function handleRequest(request) {\n try {\n const url = new URL(request.url);\n const hostname = url.hostname.toLowerCase();\n\n // 过滤非目标域名\n if (!hostname.endsWith(CONFIG.domain)) {\n return new Response('Not Found', { status: 404 });\n }\n\n // 提取子域名(如 emby、fnos 等)\n const subdomain = hostname === CONFIG.domain \n ? '' \n : hostname.slice(0, -CONFIG.domain.length - 1);\n\n // 从 CF-Connecting-IP 判断客户端 IP 版本\n const clientIP = request.headers.get('CF-Connecting-IP') || '';\n const config = clientIP.includes(':') ? CONFIG.v6 : CONFIG.v4;\n\n // 构建目标域名和完整路径\n const targetDomain = subdomain \n ? ${subdomain}.${config.target} \n : config.target;\n const fullPath = url.pathname + url.search + url.hash;\n\n // 检测是否为浏览器(用于决定跳转方式)\n const ua = request.headers.get('User-Agent') || '';\n const isBrowser = /Mozilla|Chrome|Safari|Edge|Firefox/i.test(ua) \u0026\u0026 \n !/Emby|Kodi|Infuse|Plex|curl|wget|python|java/i.test(ua);\n\n // 浏览器:返回 HTML 页面,使用 JS 跳转(保持密码填充)\n if (isBrowser) {\n const html = \u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n\u003chead\u003e\n \u003cmeta charset=\"UTF-8\"\u003e\n \u003ctitle\u003e跳转中...\u003c/title\u003e\n \u003cscript\u003e\n // 立即跳转到目标地址\n location.replace('https://${targetDomain}:${config.port}${fullPath}');\n \u003c/script\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n \u003cp\u003e正在跳转,请稍候...\u003c/p\u003e\n\u003c/body\u003e\n\u003c/html\u003e;\n\n return new Response(html, {\n headers: {\n 'Content-Type': 'text/html;charset=UTF-8',\n 'Cache-Control': 'no-cache, no-store, must-revalidate'\n }\n });\n }\n\n // 非浏览器(App/API):使用 307 重定向\n return Response.redirect(\n https://${targetDomain}:${config.port}${fullPath}, \n 307\n );\n\n } catch (error) {\n return new Response('Service Temporarily Unavailable', { \n status: 500,\n headers: { 'Content-Type': 'text/plain' }\n });\n }\n}",
"tags": null,
"deployment_id": "9b04465c4c1846709d3fb7646ae72016",
"tail_consumers": null,
"logpush": false,
"has_assets": false,
"has_modules": true,
"etag": "71ae1bcf4435285ffb29807399e721fd91b62ad8d517aa55210d920207881894",
"handlers": [
"fetch"
],
"last_deployed_from": "dash",
"usage_model": "standard",
"script": "// ===========================================\n// Cloudflare Workers 智能重定向脚本\n// 配合 Lucky STUN 穿透实现 IPv4/IPv6 自动分流\n// \n// 使用说明:\n// 1. 将下方 CONFIG 中的 '123.xyz' 替换为你的主域名\n// 2. 确保 WebHook 能自动更新 v4.port 的值\n// 3. 部署到 Cloudflare Workers\n// ===========================================\n\nconst CONFIG = {\n domain: '1340839.xyz', // 请替换为你的主域名\n v4: {\n target: 'ipv4.1340839.xyz', // IPv4 目标域名(需替换)\n port: Number(6666) || 80 // 由 WebHook 自动更新\n },\n v6: {\n target: 'ipv6.1340839.xyz', // IPv6 目标域名(需替换)\n port: 38989 // IPv6 固定端口\n }\n};\n\naddEventListener('fetch', event =\u003e {\n event.respondWith(handleRequest(event.request));\n});\n\nasync function handleRequest(request) {\n try {\n const url = new URL(request.url);\n const hostname = url.hostname.toLowerCase();\n\n // 过滤非目标域名\n if (!hostname.endsWith(CONFIG.domain)) {\n return new Response('Not Found', { status: 404 });\n }\n\n // 提取子域名(如 emby、fnos 等)\n const subdomain = hostname === CONFIG.domain \n ? '' \n : hostname.slice(0, -CONFIG.domain.length - 1);\n\n // 从 CF-Connecting-IP 判断客户端 IP 版本\n const clientIP = request.headers.get('CF-Connecting-IP') || '';\n const config = clientIP.includes(':') ? CONFIG.v6 : CONFIG.v4;\n\n // 构建目标域名和完整路径\n const targetDomain = subdomain \n ? ${subdomain}.${config.target} \n : config.target;\n const fullPath = url.pathname + url.search + url.hash;\n\n // 检测是否为浏览器(用于决定跳转方式)\n const ua = request.headers.get('User-Agent') || '';\n const isBrowser = /Mozilla|Chrome|Safari|Edge|Firefox/i.test(ua) \u0026\u0026 \n !/Emby|Kodi|Infuse|Plex|curl|wget|python|java/i.test(ua);\n\n // 浏览器:返回 HTML 页面,使用 JS 跳转(保持密码填充)\n if (isBrowser) {\n const html = \u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n\u003chead\u003e\n \u003cmeta charset=\"UTF-8\"\u003e\n \u003ctitle\u003e跳转中...\u003c/title\u003e\n \u003cscript\u003e\n // 立即跳转到目标地址\n location.replace('https://${targetDomain}:${config.port}${fullPath}');\n \u003c/script\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n \u003cp\u003e正在跳转,请稍候...\u003c/p\u003e\n\u003c/body\u003e\n\u003c/html\u003e;\n\n return new Response(html, {\n headers: {\n 'Content-Type': 'text/html;charset=UTF-8',\n 'Cache-Control': 'no-cache, no-store, must-revalidate'\n }\n });\n }\n\n // 非浏览器(App/API):使用 307 重定向\n return Response.redirect(\n https://${targetDomain}:${config.port}${fullPath}, \n 307\n );\n\n } catch (error) {\n return new Response('Service Temporarily Unavailable', { \n status: 500,\n headers: { 'Content-Type': 'text/plain' }\n });\n }\n}",
"size": 1611,
"startup_time_ms": 0
},
"success": true,
"errors": [],
"messages": []
}**
帮忙看下 怎么总是不成功啊