headers-api-everywhere: Add headers to all api calls

This commit is contained in:
Colin Campbell 2024-08-22 10:11:00 +02:00
parent 788d6c9c1f
commit 95a4d9f357

14
src/libs/fetcher.ts Normal file
View File

@ -0,0 +1,14 @@
import { getCustomOllamaHeaders } from "@/services/app"
const fetcher = async (input: string | URL | globalThis.Request, init?: RequestInit) : Promise<Response> => {
const update = {...init} || {}
const customHeaders = await getCustomOllamaHeaders()
update.headers = {
...customHeaders,
...update?.headers
}
return fetch(input, update)
}
export default fetcher