From 3fa713253412b1fc890f04599bb9882ec9dafb35 Mon Sep 17 00:00:00 2001 From: Milo Schwartz Date: Wed, 5 Feb 2025 21:32:49 -0500 Subject: [PATCH 01/35] fix update resource without subdomain --- server/routers/resource/updateResource.ts | 32 +++++++++++-------- .../resources/ResourcesSplashCard.tsx | 2 +- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/server/routers/resource/updateResource.ts b/server/routers/resource/updateResource.ts index 94958978..f7dcf6ea 100644 --- a/server/routers/resource/updateResource.ts +++ b/server/routers/resource/updateResource.ts @@ -175,10 +175,10 @@ export async function updateResource( ); } - let fullDomain = ""; + let fullDomain: string | undefined; if (updateData.isBaseDomain) { fullDomain = org.domain; - } else { + } else if (updateData.subdomain) { fullDomain = `${updateData.subdomain}.${org.domain}`; } @@ -187,18 +187,24 @@ export async function updateResource( ...(fullDomain && { fullDomain }) }; - const [existingDomain] = await db - .select() - .from(resources) - .where(eq(resources.fullDomain, fullDomain)); + if ( + fullDomain && + (updatePayload.subdomain !== undefined || + updatePayload.isBaseDomain !== undefined) + ) { + const [existingDomain] = await db + .select() + .from(resources) + .where(eq(resources.fullDomain, fullDomain)); - if (existingDomain && existingDomain.resourceId !== resourceId) { - return next( - createHttpError( - HttpCode.CONFLICT, - "Resource with that domain already exists" - ) - ); + if (existingDomain && existingDomain.resourceId !== resourceId) { + return next( + createHttpError( + HttpCode.CONFLICT, + "Resource with that domain already exists" + ) + ); + } } const updatedResource = await db diff --git a/src/app/[orgId]/settings/resources/ResourcesSplashCard.tsx b/src/app/[orgId]/settings/resources/ResourcesSplashCard.tsx index 9f857080..d16a0a57 100644 --- a/src/app/[orgId]/settings/resources/ResourcesSplashCard.tsx +++ b/src/app/[orgId]/settings/resources/ResourcesSplashCard.tsx @@ -42,7 +42,7 @@ export const ResourcesSplashCard = () => { Resources

- Resources are proxies to applications running on your private network. Create a resource for any HTTP or HTTPS app on your private network. + Resources are proxies to applications running on your private network. Create a resource for any HTTP/HTTPS or raw TCP/UDP service on your private network. Each resource must be connected to a site to enable private, secure connectivity through an encrypted WireGuard tunnel.