Skip to content

Commit ef6038f

Browse files
committed
fix: translations in production
1 parent d63c333 commit ef6038f

1 file changed

Lines changed: 12 additions & 9 deletions

File tree

src/components/PostCard.tsx

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,18 @@ const BetterContext = ({ context }: { context?: string }) => {
6363
const PostDropdownMenu = ({ post, setTranslatedText }: { post: BSkyPost; setTranslatedText: (text: string) => void }) => {
6464
const handleTranslate = async (event: React.MouseEvent<HTMLDivElement>) => {
6565
event.stopPropagation();
66-
const response = await fetch('http://localhost:8787', {
67-
method: 'POST',
68-
body: JSON.stringify({
69-
q: post.record.text,
70-
source: post.record.langs?.[0] ?? 'auto',
71-
target: navigator.language,
72-
}),
73-
headers: { 'Content-Type': 'application/json' },
74-
});
66+
const response = await fetch(
67+
process.env.NODE_ENV === 'production' ? 'https://translate.akari.blue' : 'http://localhost:8787',
68+
{
69+
method: 'POST',
70+
body: JSON.stringify({
71+
q: post.record.text,
72+
source: post.record.langs?.[0] ?? 'auto',
73+
target: navigator.language,
74+
}),
75+
headers: { 'Content-Type': 'application/json' },
76+
},
77+
);
7578
const json = (await response.json()) as {
7679
alternatives: [];
7780
detectedLanguage: {

0 commit comments

Comments
 (0)