fix: Google TTS CORS 우회 — Vite 프록시 /api/gtts 추가

This commit is contained in:
Nan Kyung Lee 2026-03-24 15:59:33 +09:00
부모 4ab7990e5d
커밋 d53eff8287
2개의 변경된 파일11개의 추가작업 그리고 1개의 파일을 삭제

파일 보기

@ -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);

파일 보기

@ -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',
},
},
},
},
}))