fix: replace img host (#3691)

This commit is contained in:
Archer
2025-02-05 10:21:35 +08:00
committed by GitHub
parent ac95828660
commit b6e441c5eb

View File

@@ -92,7 +92,10 @@ export const loadRequestMessages = async ({
const baseURL = process.env.FE_DOMAIN; const baseURL = process.env.FE_DOMAIN;
if (!baseURL) return text; if (!baseURL) return text;
// 匹配 /api/system/img/xxx.xx 的图片链接,并追加 baseURL // 匹配 /api/system/img/xxx.xx 的图片链接,并追加 baseURL
return text.replace(/(\/api\/system\/img\/[^\s.]*\.[^\s]*)/g, (match, p1) => `${baseURL}${p1}`); return text.replace(
/(?<!https?:\/\/[^\s]*)(?:\/api\/system\/img\/[^\s.]*\.[^\s]*)/g,
(match) => `${baseURL}${match}`
);
}; };
const parseSystemMessage = ( const parseSystemMessage = (
content: string | ChatCompletionContentPartText[] content: string | ChatCompletionContentPartText[]