Files
zerobyte/app/middleware/api-client.ts
2026-02-13 18:33:34 +01:00

19 lines
557 B
TypeScript

import { createMiddleware } from "@tanstack/react-start";
import { getRequestHeaders } from "@tanstack/react-start/server";
import {
createRequestClient,
runWithRequestClient,
} from "~/lib/request-client";
import { config } from "../server/core/config";
export const apiClientMiddleware = createMiddleware().server(async ({ next }) => {
const client = createRequestClient({
baseUrl: `http://127.0.0.1:${config.port}`,
headers: {
cookie: getRequestHeaders().get("cookie") ?? "",
},
});
return runWithRequestClient(client, () => next());
});