Skip to content

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

fix: unhide all api paths in dev mode

Daniel Hougaard9dde8e0df2eb
diff --git a/backend/src/server/app.ts b/backend/src/server/app.ts
index 84291d9240..a127337caa 100644
--- a/backend/src/server/app.ts
+++ b/backend/src/server/app.ts
@@ -26,12 +26,12 @@ import { TSmtpService } from "@app/services/smtp/smtp-service";
import { TSuperAdminDALFactory } from "@app/services/super-admin/super-admin-dal";
import { globalRateLimiterCfg } from "./config/rateLimiter";
-import { addErrorsToResponseSchemas } from "./plugins/add-errors-to-response-schemas";
import { apiMetrics } from "./plugins/api-metrics";
import { fastifyErrHandler } from "./plugins/error-handler";
import { serializerCompiler, validatorCompiler, ZodTypeProvider } from "./plugins/fastify-zod";
import { fastifyIp } from "./plugins/ip";
import { maintenanceMode } from "./plugins/maintenanceMode";
+import { registerResponseSchemaHooks } from "./plugins/response-schema-hooks";
import { registerServeUI } from "./plugins/serve-ui";
import { fastifySwagger } from "./plugins/swagger";
import { registerRoutes } from "./routes";
@@ -135,7 +135,7 @@ export const main = async ({
}
);
- await server.register(addErrorsToResponseSchemas);
+ await server.register(registerResponseSchemaHooks);
// pull ip based on various proxy headers
await server.register(fastifyIp);
diff --git a/backend/src/server/plugins/add-errors-to-response-schemas.ts b/backend/src/server/plugins/response-schema-hooks.ts
similarity index 76%
rename from backend/src/server/plugins/add-errors-to-response-schemas.ts
rename to backend/src/server/plugins/response-schema-hooks.ts
index a09f34a0e9..c7e7ed844d 100644
--- a/backend/src/server/plugins/add-errors-to-response-schemas.ts
+++ b/backend/src/server/plugins/response-schema-hooks.ts
@@ -1,6 +1,8 @@
/* eslint-disable no-param-reassign */
import fp from "fastify-plugin";
+import { getConfig } from "@app/lib/config/env";
+
import { DefaultResponseErrorsSchema } from "../routes/sanitizedSchemas";
const isScimRoutes = (pathname: string) =>
@@ -8,8 +10,14 @@ const isScimRoutes = (pathname: string) =>
const isAcmeRoutes = (pathname: string) => pathname.startsWith("/api/v1/cert-manager/acme/");
-export const addErrorsToResponseSchemas = fp(async (server) => {
+export const registerResponseSchemaHooks = fp(async (server) => {
+ const appCfg = getConfig();
+
server.addHook("onRoute", (routeOptions) => {
+ if (appCfg.isDevelopmentMode) {
+ routeOptions.schema.hide = false;
+ }
+
if (
routeOptions.schema &&
routeOptions.schema.response &&