mirror of
https://github.com/MetaCubeX/metacubexd.git
synced 2024-11-10 05:15:35 +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 = () => {
|
||||
const e = endpoint()
|
||||
|
||||
if (!e) {
|
||||
return ky.create({})
|
||||
}
|
||||
|
||||
const headers = new Headers()
|
||||
|
||||
if (e.secret) {
|
||||
headers.set('Authorization', `Bearer ${e.secret}`)
|
||||
}
|
||||
|
||||
return ky.create({
|
||||
prefixUrl: e?.url,
|
||||
headers: { Authorization: e?.secret ? `Bearer ${e.secret}` : '' },
|
||||
prefixUrl: e.url,
|
||||
headers,
|
||||
})
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user