sniro23 commited on
Commit
49a648f
·
verified ·
1 Parent(s): 9ef30c9

Update frontend/src/app/page.tsx

Browse files
Files changed (1) hide show
  1. frontend/src/app/page.tsx +11 -12
frontend/src/app/page.tsx CHANGED
@@ -184,18 +184,17 @@ export default function Home() {
184
 
185
  try {
186
  const history = currentConversation.slice(0, -1).map(({ role, content }) => ({ role, content }));
187
-
188
- const backendUrl =
189
- typeof window !== "undefined" && window.location.hostname.endsWith(".hf.space")
190
- ? "https://healthifylk-vedamd--8000.hf.space/query" // HF production backend
191
-
192
-
193
- const response = await fetch(backendUrl, {
194
- method: 'POST',
195
- headers: { 'Content-Type': 'application/json' },
196
- body: JSON.stringify({ query, history }),
197
- });
198
-
199
  if (!response.ok) {
200
  const errorData = await response.json().catch(() => ({ detail: 'An unknown error occurred.' }));
201
  throw new Error(errorData.detail || 'Network response was not ok');
 
184
 
185
  try {
186
  const history = currentConversation.slice(0, -1).map(({ role, content }) => ({ role, content }));
187
+
188
+ let backendUrl = "http://localhost:8000/query"; // default for local dev
189
+ if (typeof window !== "undefined" && window.location.hostname.endsWith(".hf.space")) {
190
+ backendUrl = "https://healthifylk-vedamd--8000.hf.space/query"; // production
191
+ }
192
+
193
+ const response = await fetch(backendUrl, {
194
+ method: 'POST',
195
+ headers: { 'Content-Type': 'application/json' },
196
+ body: JSON.stringify({ query, history }),
197
+ });
 
198
  if (!response.ok) {
199
  const errorData = await response.json().catch(() => ({ detail: 'An unknown error occurred.' }));
200
  throw new Error(errorData.detail || 'Network response was not ok');