mirror of
https://github.com/MetaCubeX/metacubexd.git
synced 2024-12-27 07:34:12 +08:00
refactor: set api authorization headers
This commit is contained in:
parent
fd1153709e
commit
8483d313c5
@ -26,9 +26,19 @@ export const [endpointList, setEndpointList] = makePersisted(
|
|||||||
export const useRequest = () => {
|
export const useRequest = () => {
|
||||||
const e = endpoint()
|
const e = endpoint()
|
||||||
|
|
||||||
|
if (!e) {
|
||||||
|
return ky.create({})
|
||||||
|
}
|
||||||
|
|
||||||
|
const headers = new Headers()
|
||||||
|
|
||||||
|
if (e.secret) {
|
||||||
|
headers.set('Authorization', `Bearer ${e.secret}`)
|
||||||
|
}
|
||||||
|
|
||||||
return ky.create({
|
return ky.create({
|
||||||
prefixUrl: e?.url,
|
prefixUrl: e.url,
|
||||||
headers: { Authorization: e?.secret ? `Bearer ${e.secret}` : '' },
|
headers,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user