import { createCsrfMiddleware, createStart } from "@tanstack/react-start";
import { httpErrorAdapter } from "~/lib/http-error-adapter";
import { paymentErrorMiddleware } from "~/fns/middleware";
/**
* The worker-level gate in server.ts only checks unsafe methods; this also covers GET server functions,
* so a cross-site page can't trigger one with the viewer's cookie even if it has side effects.
*/
const csrfMiddleware = createCsrfMiddleware({
filter: (ctx) => ctx.handlerType === "serverFn",
});
export const startInstance = createStart(() => ({
requestMiddleware: [csrfMiddleware],
serializationAdapters: [httpErrorAdapter],
functionMiddleware: [paymentErrorMiddleware],
}));