Owen Schwartz před 5 měsíci
rodič
revize
d064d3c7b5

+ 1 - 1
server/routers/target/createTarget.ts

@@ -23,7 +23,7 @@ const createTargetParamsSchema = z
 
 
 const createTargetSchema = z
 const createTargetSchema = z
     .object({
     .object({
-        ip: z.string().ip(),
+        ip: z.string().ip().or(z.literal('localhost')),
         method: z.string().min(1).max(10),
         method: z.string().min(1).max(10),
         port: z.number().int().min(1).max(65535),
         port: z.number().int().min(1).max(65535),
         protocol: z.string().optional(),
         protocol: z.string().optional(),

+ 1 - 1
server/routers/target/updateTarget.ts

@@ -19,7 +19,7 @@ const updateTargetParamsSchema = z
 
 
 const updateTargetBodySchema = z
 const updateTargetBodySchema = z
     .object({
     .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(),
         method: z.string().min(1).max(10).optional(),
         port: z.number().int().min(1).max(65535).optional(),
         port: z.number().int().min(1).max(65535).optional(),
         enabled: z.boolean().optional()
         enabled: z.boolean().optional()

+ 2 - 5
src/app/[orgId]/settings/resources/[resourceId]/connectivity/page.tsx

@@ -59,20 +59,17 @@ import {
     SettingsSectionTitle,
     SettingsSectionTitle,
     SettingsSectionDescription,
     SettingsSectionDescription,
     SettingsSectionBody,
     SettingsSectionBody,
-    SettingsSectionForm,
     SettingsSectionFooter
     SettingsSectionFooter
 } from "@app/components/Settings";
 } from "@app/components/Settings";
 import { SwitchInput } from "@app/components/SwitchInput";
 import { SwitchInput } from "@app/components/SwitchInput";
 
 
 const addTargetSchema = z.object({
 const addTargetSchema = z.object({
-    ip: z.string().ip(),
+    ip: z.string().ip().or(z.literal('localhost')),
     method: z.string(),
     method: z.string(),
     port: z.coerce.number().int().positive()
     port: z.coerce.number().int().positive()
     // protocol: z.string(),
     // protocol: z.string(),
 });
 });
 
 
-type AddTargetFormValues = z.infer<typeof addTargetSchema>;
-
 type LocalTarget = Omit<
 type LocalTarget = Omit<
     ArrayElement<ListTargetsResponse["targets"]> & {
     ArrayElement<ListTargetsResponse["targets"]> & {
         new?: boolean;
         new?: boolean;
@@ -182,7 +179,7 @@ export default function ReverseProxyTargets(props: {
             // make sure that the target IP is within the site subnet
             // make sure that the target IP is within the site subnet
             const targetIp = data.ip;
             const targetIp = data.ip;
             const subnet = site.subnet;
             const subnet = site.subnet;
-            if (!isIPInSubnet(targetIp, subnet)) {
+            if (targetIp === "localhost" || !isIPInSubnet(targetIp, subnet)) {
                 toast({
                 toast({
                     variant: "destructive",
                     variant: "destructive",
                     title: "Invalid target IP",
                     title: "Invalid target IP",