Skip to content

Commit e51ba46

Browse files
committed
Address review comments
1 parent 5fca9b3 commit e51ba46

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

kyuubi-server/web-ui/src/utils/request.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { useAuthStore } from '@/pinia/auth/auth'
1919

2020
interface RequestConfig {
2121
url: string
22-
method: string
22+
method: 'get' | 'post' | 'put' | 'delete'
2323
data?: unknown
2424
params?: Record<string, any>
2525
auth?: { username: string; password: string }
@@ -43,7 +43,8 @@ async function request(config: RequestConfig): Promise<unknown> {
4343
headers['Content-Type'] = 'application/json'
4444
}
4545

46-
let fullUrl = url
46+
// Ensure absolute path to avoid resolving relative to the app's base path (/ui/)
47+
let fullUrl = url.startsWith('/') ? url : `/${url}`
4748
if (params) {
4849
const searchParams = new URLSearchParams()
4950
for (const [key, value] of Object.entries(params)) {
@@ -53,7 +54,7 @@ async function request(config: RequestConfig): Promise<unknown> {
5354
}
5455
const queryString = searchParams.toString()
5556
if (queryString) {
56-
fullUrl = `${url}?${queryString}`
57+
fullUrl = `${fullUrl}?${queryString}`
5758
}
5859
}
5960

@@ -77,7 +78,8 @@ async function request(config: RequestConfig): Promise<unknown> {
7778
return undefined
7879
}
7980

80-
return response.json()
81+
const text = await response.text()
82+
return text ? JSON.parse(text) : undefined
8183
}
8284

8385
export default request

0 commit comments

Comments
 (0)