Commit ·
3538827
1
Parent(s): 444847b
Fix API baseURL for relative paths in production
Browse files- client/lib/api.ts +7 -1
client/lib/api.ts
CHANGED
|
@@ -1,8 +1,14 @@
|
|
| 1 |
import axios from 'axios';
|
| 2 |
|
| 3 |
// Configure axios to connect to FastAPI backend
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
const apiClient = axios.create({
|
| 5 |
-
baseURL:
|
| 6 |
timeout: 180000, // 3 minute timeout for analysis
|
| 7 |
});
|
| 8 |
|
|
|
|
| 1 |
import axios from 'axios';
|
| 2 |
|
| 3 |
// Configure axios to connect to FastAPI backend
|
| 4 |
+
// If NEXT_PUBLIC_API_URL is provided, use it. Otherwise, use relative paths (empty string)
|
| 5 |
+
// which works perfectly when serving frontend and backend from the same Docker container.
|
| 6 |
+
const apiBaseUrl = process.env.NEXT_PUBLIC_API_URL !== undefined
|
| 7 |
+
? process.env.NEXT_PUBLIC_API_URL
|
| 8 |
+
: 'http://127.0.0.1:8000';
|
| 9 |
+
|
| 10 |
const apiClient = axios.create({
|
| 11 |
+
baseURL: apiBaseUrl,
|
| 12 |
timeout: 180000, // 3 minute timeout for analysis
|
| 13 |
});
|
| 14 |
|