diff --git a/server/lib/config.ts b/server/lib/config.ts index 66dd6764..14e96af1 100644 --- a/server/lib/config.ts +++ b/server/lib/config.ts @@ -60,7 +60,6 @@ const configSchema = z.object({ .transform(stoi) .pipe(portSchema), internal_hostname: z.string().transform((url) => url.toLowerCase()), - secure_cookies: z.boolean(), session_cookie_name: z.string(), resource_access_token_param: z.string(), resource_session_request_param: z.string(), diff --git a/src/app/[orgId]/settings/resources/CreateResourceForm.tsx b/src/app/[orgId]/settings/resources/CreateResourceForm.tsx index 753d843d..11f215d4 100644 --- a/src/app/[orgId]/settings/resources/CreateResourceForm.tsx +++ b/src/app/[orgId]/settings/resources/CreateResourceForm.tsx @@ -62,6 +62,7 @@ import { import { subdomainSchema } from "@server/schemas/subdomainSchema"; import Link from "next/link"; import { SquareArrowOutUpRight } from "lucide-react"; +import CopyTextBox from "@app/components/CopyTextBox"; const createResourceFormSchema = z .object({ @@ -129,6 +130,10 @@ export default function CreateResourceForm({ const [sites, setSites] = useState([]); const [domainSuffix, setDomainSuffix] = useState(org.org.domain); + const [showSnippets, setShowSnippets] = useState(false); + + const [resourceId, setResourceId] = useState(null); + const form = useForm({ resolver: zodResolver(createResourceFormSchema), defaultValues: { @@ -186,11 +191,21 @@ export default function CreateResourceForm({ if (res && res.status === 201) { const id = res.data.data.resourceId; - // navigate to the resource page - router.push(`/${orgId}/settings/resources/${id}`); + setResourceId(id); + + if (data.http) { + goToResource(); + } else { + setShowSnippets(true); + } } } + function goToResource() { + // navigate to the resource page + router.push(`/${orgId}/settings/resources/${resourceId}`); + } + return ( <> -
- - ( - - Name - - - - - This is the name that will be - displayed for this resource. - - - - )} - /> - - {!env.flags.allowRawResources || ( + {!showSnippets && ( + + ( - -
- - HTTP Resource - - - Toggle if this is an - HTTP resource or a raw - TCP/UDP resource - -
- - - -
- )} - /> - )} - - {form.watch("http") && ( - ( - Subdomain + Name - - form.setValue( - "subdomain", - value - ) - } + - This is the fully qualified - domain name that will be - used to access the resource. + This is the name that will + be displayed for this + resource. )} /> - )} - {!form.watch("http") && ( - - - Learn how to configure TCP/UDP resources - - - - )} - - {!form.watch("http") && ( - <> + {!env.flags.allowRawResources || ( ( - - - Protocol - - - - The protocol to use for - the resource - - + +
+ + HTTP Resource + + + Toggle if this is an + HTTP resource or a + raw TCP/UDP resource + +
+ + +
)} /> + )} + + {form.watch("http") && ( ( - Port Number + Subdomain - - field.onChange( - e.target - .value - ? parseInt( - e - .target - .value - ) - : null + domainSuffix={ + domainSuffix + } + placeholder="Enter subdomain" + onChange={(value) => + form.setValue( + "subdomain", + value ) } /> - The port number to proxy - requests to (required - for non-HTTP resources) + This is the fully + qualified domain name + that will be used to + access the resource. )} /> - - )} - - ( - - Site - - - - - - - - - - - - No site found. - - - {sites.map( - (site) => ( - { - form.setValue( - "siteId", - site.siteId - ); - }} - > - - { - site.name - } - - ) - )} - - - - - - - This is the site that will be - used in the dashboard. - - - )} - /> - - + + {!form.watch("http") && ( + + + Learn how to configure TCP/UDP + resources + + + + )} + + {!form.watch("http") && ( + <> + ( + + + Protocol + + + + The protocol to use + for the resource + + + + )} + /> + ( + + + Port Number + + + + field.onChange( + e.target + .value + ? parseInt( + e + .target + .value + ) + : null + ) + } + /> + + + The port number to + proxy requests to + (required for + non-HTTP resources) + + + + )} + /> + + )} + + ( + + Site + + + + + + + + + + + + No site + found. + + + {sites.map( + ( + site + ) => ( + { + form.setValue( + "siteId", + site.siteId + ); + }} + > + + { + site.name + } + + ) + )} + + + + + + + This is the site that will + be used in the dashboard. + + + + )} + /> + + + )} + + {showSnippets && ( +
+
+
+ 1 +
+
+

+ Traefik: Add Entrypoints +

+ +
+
+ +
+
+ 2 +
+
+

+ Gerbil: Expose Ports in Docker + Compose +

+ +
+
+ + + + Make sure to follow the full guide + + + +
+ )}
- + } + + {showSnippets && } + diff --git a/src/app/[orgId]/settings/resources/[resourceId]/connectivity/page.tsx b/src/app/[orgId]/settings/resources/[resourceId]/connectivity/page.tsx index c40102e3..3c2b54c6 100644 --- a/src/app/[orgId]/settings/resources/[resourceId]/connectivity/page.tsx +++ b/src/app/[orgId]/settings/resources/[resourceId]/connectivity/page.tsx @@ -130,7 +130,7 @@ export default function ReverseProxyTargets(props: { const addTargetForm = useForm({ resolver: zodResolver(addTargetSchema), defaultValues: { - ip: "localhost", + ip: "", method: resource.http ? "http" : null, port: resource.http ? 80 : resource.proxyPort || 1234 // protocol: "TCP",