Merge pull request #3437 from imfangwenjie/fix/api-base-fetch

fix(frontend): use configured API base for direct requests
This commit is contained in:
Wesley Liddick
2026-06-29 09:23:13 +08:00
committed by GitHub
13 changed files with 72 additions and 45 deletions
+5 -4
View File
@@ -4,7 +4,7 @@
* - Dashboard overview (raw path)
*/
import { apiClient } from '../client'
import { apiClient, buildGatewayUrl } from '../client'
import type { PaginatedResponse } from '@/types'
export type OpsQueryMode = 'auto' | 'raw' | 'preagg'
@@ -593,9 +593,10 @@ export function subscribeQPS(onMessage: (data: any) => void, options: SubscribeQ
isConnecting = true
setStatus(hasConnectedOnce ? 'reconnecting' : 'connecting')
const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:'
const wsBaseUrl = options.wsBaseUrl || import.meta.env.VITE_WS_BASE_URL || window.location.host
const wsURL = new URL(`${protocol}//${wsBaseUrl}/api/v1/admin/ops/ws/qps`)
const wsBaseUrl = options.wsBaseUrl || import.meta.env.VITE_WS_BASE_URL
const wsURL = wsBaseUrl
? new URL(`${window.location.protocol === 'https:' ? 'wss:' : 'ws:'}//${wsBaseUrl}/api/v1/admin/ops/ws/qps`)
: new URL(buildGatewayUrl('/api/v1/admin/ops/ws/qps').replace(/^http/, 'ws'))
// Do NOT put admin JWT in the URL query string (it can leak via access logs, proxies, etc).
// Browsers cannot set Authorization headers for WebSockets, so we pass the token via