fix:环境变量

This commit is contained in:
吕新雨
2026-02-03 02:36:42 +08:00
parent 8c02c5b9a0
commit 4c450db9b2
5 changed files with 53 additions and 15 deletions

View File

@@ -37,20 +37,30 @@ export async function fetchRecoFeed(req: RecoRequest): Promise<RecoEngineResult>
const url = `${API_BASE_URL}/v1/reco/feed`;
const acceptLanguage = i18n.language?.toLowerCase().startsWith('zh') ? 'tc' : 'en';
const headers: Record<string, string> = {
'Content-Type': 'application/json',
// 让后端做 locale 选择(目前后端只区分 en/tc
'Accept-Language': acceptLanguage,
};
const bodyObj = {
k: req.k,
user_profile: req.user_profile,
already_recommended_ids: req.already_recommended_ids ?? [],
touched_or_viewed_ids: req.touched_or_viewed_ids ?? [],
now: req.now,
};
// 仅在开发环境打印,避免生产环境日志泄露敏感信息
if (__DEV__) {
console.log('[Feed API] 请求地址:', url);
console.log('[Feed API] Feed的API请求头:', headers);
console.log('[Feed API] Feed的API请求体:', bodyObj);
}
const res = await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
// 让后端做 locale 选择(目前后端只区分 en/tc
'Accept-Language': acceptLanguage,
},
body: JSON.stringify({
k: req.k,
user_profile: req.user_profile,
already_recommended_ids: req.already_recommended_ids ?? [],
touched_or_viewed_ids: req.touched_or_viewed_ids ?? [],
now: req.now,
}),
headers,
body: JSON.stringify(bodyObj),
signal: controller.signal,
});