From ef6038fc759fdb323f81250da2681cec0866c0b9 Mon Sep 17 00:00:00 2001 From: luna Date: Thu, 9 Jan 2025 18:17:58 +1030 Subject: [PATCH] fix: translations in production --- src/components/PostCard.tsx | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/components/PostCard.tsx b/src/components/PostCard.tsx index 10263bc..1e85bab 100644 --- a/src/components/PostCard.tsx +++ b/src/components/PostCard.tsx @@ -63,15 +63,18 @@ const BetterContext = ({ context }: { context?: string }) => { const PostDropdownMenu = ({ post, setTranslatedText }: { post: BSkyPost; setTranslatedText: (text: string) => void }) => { const handleTranslate = async (event: React.MouseEvent) => { event.stopPropagation(); - const response = await fetch('http://localhost:8787', { - method: 'POST', - body: JSON.stringify({ - q: post.record.text, - source: post.record.langs?.[0] ?? 'auto', - target: navigator.language, - }), - headers: { 'Content-Type': 'application/json' }, - }); + const response = await fetch( + process.env.NODE_ENV === 'production' ? 'https://translate.akari.blue' : 'http://localhost:8787', + { + method: 'POST', + body: JSON.stringify({ + q: post.record.text, + source: post.record.langs?.[0] ?? 'auto', + target: navigator.language, + }), + headers: { 'Content-Type': 'application/json' }, + }, + ); const json = (await response.json()) as { alternatives: []; detectedLanguage: {