Files
Folo/apps/server/client/lib/api-fetch.ts
T
DIYgod 9102203956 feat: migrate to better auth (#1951)
* feat: add better-auth

* feat: remove hono/auth-js

* fix: authention check

* fix: signout refetch

* feat: init server auth plugins

* feat: remove types/authjs

* feat: server auth create session plugin

* feat: web login returning

* fix: types

* fix: test env
2024-12-03 12:59:41 +08:00

28 lines
692 B
TypeScript

import { env } from "@follow/shared/env"
import type { AppType } from "@follow/shared/hono"
import { hc } from "hono/client"
import { ofetch } from "ofetch"
const apiFetch = ofetch.create({
credentials: "include",
retry: false,
onRequest: ({ options }) => {
const header = new Headers(options.headers)
header.set("x-app-version", "Web External")
options.headers = header
},
})
export const apiClient = hc<AppType>(env.VITE_EXTERNAL_API_URL || env.VITE_API_URL, {
fetch: async (input: any, options = {}) =>
apiFetch(input.toString(), options).catch((err) => {
throw err
}),
headers() {
return {
"X-App-Version": "Web External",
}
},
})