diff --git a/server/routers/target/createTarget.ts b/server/routers/target/createTarget.ts index 478c8d2a3c8a6de4a780ef1937a673618cce1929..742cdf684471cfd75748677ce67bc56877fb168a 100644 --- a/server/routers/target/createTarget.ts +++ b/server/routers/target/createTarget.ts @@ -23,7 +23,7 @@ const createTargetParamsSchema = z const createTargetSchema = z .object({ - ip: z.string().ip(), + ip: z.string().ip().or(z.literal('localhost')), method: z.string().min(1).max(10), port: z.number().int().min(1).max(65535), protocol: z.string().optional(), diff --git a/server/routers/target/updateTarget.ts b/server/routers/target/updateTarget.ts index 448f5018cd9e869e96f09d32eeca8a41727d5bba..3e2880203b080d8e6c5fa63a237512fe4a147fc2 100644 --- a/server/routers/target/updateTarget.ts +++ b/server/routers/target/updateTarget.ts @@ -19,7 +19,7 @@ const updateTargetParamsSchema = z const updateTargetBodySchema = z .object({ - ip: z.string().ip().optional(), // for now we cant update the ip; you will have to delete + ip: z.string().ip().or(z.literal('localhost')).optional(), // for now we cant update the ip; you will have to delete method: z.string().min(1).max(10).optional(), port: z.number().int().min(1).max(65535).optional(), enabled: z.boolean().optional() diff --git a/src/app/[orgId]/settings/resources/[resourceId]/connectivity/page.tsx b/src/app/[orgId]/settings/resources/[resourceId]/connectivity/page.tsx index c01cbd5dc17bffbda0ae60c063c908d2ed59bf2b..0dad760bd084c8329a6ad2b638203416eeb9b2e2 100644 --- a/src/app/[orgId]/settings/resources/[resourceId]/connectivity/page.tsx +++ b/src/app/[orgId]/settings/resources/[resourceId]/connectivity/page.tsx @@ -59,20 +59,17 @@ import { SettingsSectionTitle, SettingsSectionDescription, SettingsSectionBody, - SettingsSectionForm, SettingsSectionFooter } from "@app/components/Settings"; import { SwitchInput } from "@app/components/SwitchInput"; const addTargetSchema = z.object({ - ip: z.string().ip(), + ip: z.string().ip().or(z.literal('localhost')), method: z.string(), port: z.coerce.number().int().positive() // protocol: z.string(), }); -type AddTargetFormValues = z.infer; - type LocalTarget = Omit< ArrayElement & { new?: boolean; @@ -182,7 +179,7 @@ export default function ReverseProxyTargets(props: { // make sure that the target IP is within the site subnet const targetIp = data.ip; const subnet = site.subnet; - if (!isIPInSubnet(targetIp, subnet)) { + if (targetIp === "localhost" || !isIPInSubnet(targetIp, subnet)) { toast({ variant: "destructive", title: "Invalid target IP",