Commit ·
d061a75
1
Parent(s): 702b8ab
fix: use same-origin API base in deployed frontend
Browse files
frontend/src/api/client.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
import axios from "axios";
|
| 2 |
|
| 3 |
-
const
|
|
|
|
| 4 |
|
| 5 |
const api = axios.create({ baseURL: BASE_URL, timeout: 30000 });
|
| 6 |
|
|
@@ -107,7 +108,9 @@ export async function listJobs() {
|
|
| 107 |
}
|
| 108 |
|
| 109 |
export function createSSEConnection(jobId, onEvent) {
|
| 110 |
-
const url = BASE_URL
|
|
|
|
|
|
|
| 111 |
const source = new EventSource(url);
|
| 112 |
let connected = false;
|
| 113 |
let done = false;
|
|
|
|
| 1 |
import axios from "axios";
|
| 2 |
|
| 3 |
+
const configuredBaseUrl = import.meta.env.VITE_API_URL?.trim();
|
| 4 |
+
const BASE_URL = configuredBaseUrl || "";
|
| 5 |
|
| 6 |
const api = axios.create({ baseURL: BASE_URL, timeout: 30000 });
|
| 7 |
|
|
|
|
| 108 |
}
|
| 109 |
|
| 110 |
export function createSSEConnection(jobId, onEvent) {
|
| 111 |
+
const url = BASE_URL
|
| 112 |
+
? BASE_URL + "/api/analysis/" + jobId + "/stream"
|
| 113 |
+
: "/api/analysis/" + jobId + "/stream";
|
| 114 |
const source = new EventSource(url);
|
| 115 |
let connected = false;
|
| 116 |
let done = false;
|