fix: Google TTS CORS 우회 — Vite 프록시 /api/gtts 추가
This commit is contained in:
부모
4ab7990e5d
커밋
d53eff8287
@ -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',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}))
|
||||
|
||||
불러오는 중...
Reference in New Issue
Block a user