feat(domains): add internal path routing and

strip path functionality to compose

  - Add internalPath field to route requests
  to different paths internally
  - Add stripPath option to remove external
  path prefix before forwarding
  - Improves validation for stripPath (requires
  non-root path) and internalPath (must start
  with /)
This commit is contained in:
Jhonatan Caldeira
2025-06-22 14:55:27 -03:00
parent df8f1252a0
commit fd0f679d0f
3 changed files with 80 additions and 0 deletions

View File

@@ -86,6 +86,24 @@ export const domain = z
message: "Required",
});
}
// Validate stripPath requires a valid path
if (input.stripPath && (!input.path || input.path === "/")) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
path: ["stripPath"],
message: "Strip path can only be enabled when a path other than '/' is specified",
});
}
// Validate internalPath starts with /
if (input.internalPath && input.internalPath !== "/" && !input.internalPath.startsWith("/")) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
path: ["internalPath"],
message: "Internal path must start with '/'",
});
}
});
type Domain = z.infer<typeof domain>;