feat(start): csrf middleware for server functions
This commit is contained in:
+6
-1
@@ -1,8 +1,13 @@
|
|||||||
import { createStart } from "@tanstack/react-start";
|
import { createCsrfMiddleware, createStart } from "@tanstack/react-start";
|
||||||
import { serverFnLoggingMiddleware } from "@/utils/activities";
|
import { serverFnLoggingMiddleware } from "@/utils/activities";
|
||||||
|
|
||||||
|
const csrfMiddleware = createCsrfMiddleware({
|
||||||
|
filter: (ctx) => ctx.handlerType === "serverFn",
|
||||||
|
});
|
||||||
|
|
||||||
// Global function middleware: every server fn (current and future) is audited
|
// Global function middleware: every server fn (current and future) is audited
|
||||||
// without opting in at the definition site.
|
// without opting in at the definition site.
|
||||||
export const startInstance = createStart(() => ({
|
export const startInstance = createStart(() => ({
|
||||||
|
requestMiddleware: [csrfMiddleware],
|
||||||
functionMiddleware: [serverFnLoggingMiddleware],
|
functionMiddleware: [serverFnLoggingMiddleware],
|
||||||
}));
|
}));
|
||||||
|
|||||||
Reference in New Issue
Block a user