client.current and createScopedClient resolve transport via dispatchFor: web -> absolute origin + /api base with an X-Honcho-Upstream header; Tauri -> absolute instance URL + reqwest. Absolute base (not bare "/api") so openapi-fetch can construct a Request under node/undici and in the browser alike. Fleet fan-out is unchanged; fleet.test.tsx now asserts the proxy contract.
17 lines
494 B
TypeScript
17 lines
494 B
TypeScript
import createClient from "openapi-fetch";
|
|
import { loadConfig } from "@/lib/config";
|
|
import { dispatchFor } from "@/lib/dispatch";
|
|
import type { paths } from "./schema.d.ts";
|
|
|
|
export function createHonchoClient() {
|
|
const config = loadConfig() ?? { baseUrl: "http://localhost:8000", token: "" };
|
|
const { baseUrl, headers, fetch } = dispatchFor(config);
|
|
return createClient<paths>({ baseUrl, headers, fetch });
|
|
}
|
|
|
|
export const client = {
|
|
get current() {
|
|
return createHonchoClient();
|
|
},
|
|
};
|