From fa4be36ebf1ece92f13ca14653f4764c9500e81f Mon Sep 17 00:00:00 2001 From: MarSeventh <1193267292@qq.com> Date: Wed, 6 May 2026 16:41:16 +0800 Subject: [PATCH] fix: wrap Docker server responses with native Response --- deploy/server/index.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/deploy/server/index.js b/deploy/server/index.js index 2cc26694..59b1bc92 100644 --- a/deploy/server/index.js +++ b/deploy/server/index.js @@ -14,6 +14,8 @@ import { fileURLToPath, pathToFileURL } from 'url'; import { SqliteD1 } from './sqliteD1.js'; import { LocalR2Storage } from './r2Storage.js'; +const NativeResponse = globalThis.Response; + // ==================== 模拟 Cloudflare 全局 API ==================== // 模拟 Cloudflare Cache API(Node.js 中不存在) @@ -392,8 +394,20 @@ app.get('*', async (c) => { // ==================== 启动服务器 ==================== +async function fetchWithNativeResponse(request, env, executionCtx) { + const response = await app.fetch(request, env, executionCtx); + if (!response) { + return response; + } + return new NativeResponse(response.body, { + status: response.status, + statusText: response.statusText, + headers: response.headers, + }); +} + serve({ - fetch: app.fetch, + fetch: fetchWithNativeResponse, port, }, (info) => { console.log(`Server running at http://0.0.0.0:${info.port}`);