From 1c153cc18c8dc089a369b80b863b7ec8cdb45fdf Mon Sep 17 00:00:00 2001 From: tim Date: Sat, 12 Jul 2025 11:29:12 +0800 Subject: [PATCH] feat: add cros --- open-isle-cli/functions/api.js | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/open-isle-cli/functions/api.js b/open-isle-cli/functions/api.js index 866c4569c..92d252ecd 100644 --- a/open-isle-cli/functions/api.js +++ b/open-isle-cli/functions/api.js @@ -1,9 +1,21 @@ +// open-isle-cli/functions/api/[...path].js export async function onRequest({ request }) { const url = new URL(request.url) - url.hostname = '129.204.254.110' - url.port = '8080' - url.protocol = 'http:' - // 直接透传:不区分 user/category - return fetch(url, request) + // 把路径原封不动转发到广州裸 IP + url.hostname = "129.204.254.110" + url.port = "8080" + url.protocol = "http:" + + const resp = await fetch(url, request) + + // 附加 CORS 头 + return new Response(resp.body, { + status: resp.status, + headers: { + ...resp.headers, + "Access-Control-Allow-Origin": "https://9ac7b637-openisle.cjt807916.workers.dev", + "Access-Control-Allow-Credentials": "true" + } + }) } \ No newline at end of file