mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-10-31 16:26:30 +00:00
Merge pull request #3437 from imfangwenjie/fix/api-base-fetch
fix(frontend): use configured API base for direct requests
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user