diff --git a/frontend/src/components/korea/OpsGuideModal.tsx b/frontend/src/components/korea/OpsGuideModal.tsx index 9625230..9e06004 100644 --- a/frontend/src/components/korea/OpsGuideModal.tsx +++ b/frontend/src/components/korea/OpsGuideModal.tsx @@ -150,7 +150,7 @@ export function OpsGuideModal({ ships, onClose, onFlyTo, onRouteSelect }: Props) if (audioRef.current) { audioRef.current.pause(); audioRef.current = null; } setSpeakingIdx(idx); const encoded = encodeURIComponent(text); - const url = `https://translate.google.com/translate_tts?ie=UTF-8&client=tw-ob&tl=zh-CN&q=${encoded}`; + const url = `/api/gtts?ie=UTF-8&client=tw-ob&tl=zh-CN&q=${encoded}`; const audio = new Audio(url); audioRef.current = audio; audio.onended = () => setSpeakingIdx(null); diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts index d81f6ba..1826b7d 100644 --- a/frontend/vite.config.ts +++ b/frontend/vite.config.ts @@ -115,6 +115,16 @@ export default defineConfig(({ mode }): UserConfig => ({ changeOrigin: true, rewrite: (path) => path.replace(/^\/ollama/, ''), }, + '/api/gtts': { + target: 'https://translate.google.com', + changeOrigin: true, + rewrite: (path) => path.replace(/^\/api\/gtts/, '/translate_tts'), + secure: true, + headers: { + 'Referer': 'https://translate.google.com/', + 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36', + }, + }, }, }, }))