mirror of
https://github.com/nicotsx/zerobyte.git
synced 2026-04-17 13:33:16 -04:00
19 lines
557 B
TypeScript
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());
|
|
});
|