diff --git a/GVSDServiceServer/venom_ui/src/api.ts b/GVSDServiceServer/venom_ui/src/api.ts index 17a394f4..9888640f 100644 --- a/GVSDServiceServer/venom_ui/src/api.ts +++ b/GVSDServiceServer/venom_ui/src/api.ts @@ -9,17 +9,17 @@ */ const API_BASE = (() => { - const proxied = /\/API\/Subscription\/RemoteAsset\/([^/]+)\//.exec(import.meta.url) + // 主服务缓存代理模式:模块 URL 形如 + // https://gerp.gvsds.com/API/Subscription/RemoteAsset//venom/remote-entry.js + // + // 注意:**不能**写成 `new URL(动态拼接串, import.meta.url)`——Vite 会把「动态首参」 + // 的 new URL 编译成静态资源表查找(`Object.assign({})[key]`),运行时取到 undefined, + // 表现为请求 `.../venom/undefined/packages/`。故这里用字符串替换自行拼接。 + const proxied = /^(.*\/API\/Subscription\/)RemoteAsset\/([^/]+)\//.exec(import.meta.url) if (proxied) { - try { - return new URL( - `/API/Subscription/RemoteApi/${proxied[1]}/api/venom`, - import.meta.url, - ).toString() - } catch { - /* 落到直连分支 */ - } + return `${proxied[1]}RemoteApi/${proxied[2]}/api/venom` } + // 未启用代理(本地直连子服务器):按当前模块地址推断同源 /api/venom try { return new URL('/api/venom', import.meta.url).toString() } catch {