@samitouri / QOSami-HFS / commits / 3a7d52ba

fix: admin/logs: new api visualization didn't work with rev-proxies

Massimo Melina committed Jul 8, 2023 at 16:07 UTC 3a7d52bada07484bef8b08b8e7fbfefaa17fe669
1 file changed +3 -3
shared/api.ts
+3 -3
@@ -4,7 +4,7 @@ import _ from 'lodash';
4 import { useCallback, useEffect, useRef } from 'react';
5 import { Dict, Falsy, getCookie, getPrefixUrl, pendingPromise, useStateMounted } from '.'
6
7 -export const API_URL = getPrefixUrl() + '/~/api/'
7 +export const API_URL = '/~/api/'
8
9 const timeoutByApi: Dict = {
10 loginSrp1: 90, // support antibrute
@@ -31,7 +31,7 @@ export function apiCall<T=any>(cmd: string, params?: Dict, options: ApiCallOptio
31 const controller = new AbortController()
32 if (options.timeout !== false)
33 setTimeout(() => controller.abort('timeout'), 1000*(timeoutByApi[cmd] ?? options.timeout ?? 10))
34 - return Object.assign(fetch(API_URL + cmd, {
34 + return Object.assign(fetch(getPrefixUrl() + API_URL + cmd, {
35 method: 'POST',
36 headers: { 'content-type': 'application/json' },
37 signal: controller.signal,
@@ -111,7 +111,7 @@ export function apiEvents(cmd: string, params: Dict, cb:EventHandler) {
111 const csrf = getCsrf()
112 if (csrf)
113 processed.csrf = JSON.stringify(csrf)
114 - const source = new EventSource(API_URL + cmd + '?' + new URLSearchParams(processed))
114 + const source = new EventSource(getPrefixUrl() + API_URL + cmd + '?' + new URLSearchParams(processed))
115 source.onopen = () => cb('connected')
116 source.onerror = err => cb('error', err)
117 source.onmessage = ({ data }) => {