Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

fix(plugins): update content type parser for application/x-www-form-urlencoded to preserve raw stream for primary forwarding

Victor Hugo dos Santos72fae5a5645c
diff --git a/backend/src/server/plugins/primary-forwarding-mode.ts b/backend/src/server/plugins/primary-forwarding-mode.ts
index 611806a6b3..6a85fa3b24 100644
--- a/backend/src/server/plugins/primary-forwarding-mode.ts
+++ b/backend/src/server/plugins/primary-forwarding-mode.ts
@@ -6,6 +6,12 @@ export const forwardWritesToPrimary = fp(async (server, opt: { primaryUrl: strin
base: opt.primaryUrl
});
+ // reply-from only re-encodes parsed JSON bodies; every other content type must stay a raw
+ // stream so it can be piped to the primary byte-for-byte (e.g. SAML callback form posts).
+ // Safe on replicas: all /api writes are forwarded, so no local route needs a parsed form body.
+ server.removeContentTypeParser("application/x-www-form-urlencoded");
+ server.addContentTypeParser("application/x-www-form-urlencoded", (_req, payload, done) => done(null, payload));
+
server.addHook("preValidation", async (request, reply) => {
if (request.url.startsWith("/api") && ["POST", "PUT", "DELETE", "PATCH"].includes(request.method)) {
return reply.from(request.url);