UNPKG

@softr/sdk

Version:

The SDK for building Softr apps on TanStack Start. It lets an app interact with Softr: auth, datasources, workflows and integrations.

25 lines (23 loc) • 728 B
import { createMiddleware } from "@tanstack/react-start"; //#region src/app-identity.ts /** * Tells support which Softr app answered, in an `x-softr-app-id` response * header. */ function appIdentityMiddleware() { return createMiddleware({ type: "request" }).server(async ({ next }) => { const result = await next(); const applicationId = process.env.SOFTR_APPLICATION_ID; if (!applicationId) return result; try { result.response.headers.set("x-softr-app-id", applicationId); return result; } catch { const response = new Response(result.response.body, result.response); response.headers.set("x-softr-app-id", applicationId); return response; } }); } //#endregion export { appIdentityMiddleware };