diff --git a/apps/sim/app/api/chat/edit/[id]/route.ts b/apps/sim/app/api/chat/edit/[id]/route.ts index 4e7595dea..e497d578e 100644 --- a/apps/sim/app/api/chat/edit/[id]/route.ts +++ b/apps/sim/app/api/chat/edit/[id]/route.ts @@ -4,7 +4,7 @@ import { z } from 'zod' import { getSession } from '@/lib/auth' import { isDev } from '@/lib/environment' import { createLogger } from '@/lib/logs/console-logger' -import { getBaseDomain } from '@/lib/urls/utils' +import { getEmailDomain } from '@/lib/urls/utils' import { encryptSecret } from '@/lib/utils' import { checkChatAccess } from '@/app/api/chat/utils' import { createErrorResponse, createSuccessResponse } from '@/app/api/workflows/utils' @@ -68,7 +68,7 @@ export async function GET(_request: NextRequest, { params }: { params: Promise<{ // Create a new result object without the password const { password, ...safeData } = chatRecord - const baseDomain = getBaseDomain() + const baseDomain = getEmailDomain() const protocol = isDev ? 'http' : 'https' const chatUrl = `${protocol}://${chatRecord.subdomain}.${baseDomain}` @@ -214,7 +214,7 @@ export async function PATCH(request: NextRequest, { params }: { params: Promise< const updatedSubdomain = subdomain || existingChat[0].subdomain - const baseDomain = getBaseDomain() + const baseDomain = getEmailDomain() const protocol = isDev ? 'http' : 'https' const chatUrl = `${protocol}://${updatedSubdomain}.${baseDomain}` diff --git a/apps/sim/app/api/chat/route.ts b/apps/sim/app/api/chat/route.ts index 65701515d..d144e19a0 100644 --- a/apps/sim/app/api/chat/route.ts +++ b/apps/sim/app/api/chat/route.ts @@ -175,7 +175,11 @@ export async function POST(request: NextRequest) { let chatUrl: string try { const url = new URL(baseUrl) - chatUrl = `${url.protocol}//${subdomain}.${url.host}` + let host = url.host + if (host.startsWith('www.')) { + host = host.substring(4) + } + chatUrl = `${url.protocol}//${subdomain}.${host}` } catch (error) { logger.warn('Failed to parse baseUrl, falling back to defaults:', { baseUrl, diff --git a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/control-bar/components/deploy-modal/components/chat-deploy/chat-deploy.tsx b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/control-bar/components/deploy-modal/components/chat-deploy/chat-deploy.tsx index a5f6507f5..5f270584a 100644 --- a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/control-bar/components/deploy-modal/components/chat-deploy/chat-deploy.tsx +++ b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/control-bar/components/deploy-modal/components/chat-deploy/chat-deploy.tsx @@ -31,7 +31,7 @@ import { Label } from '@/components/ui/label' import { Skeleton } from '@/components/ui/skeleton' import { Textarea } from '@/components/ui/textarea' import { createLogger } from '@/lib/logs/console-logger' -import { getBaseDomain } from '@/lib/urls/utils' +import { getBaseDomain, getEmailDomain } from '@/lib/urls/utils' import { cn } from '@/lib/utils' import { OutputSelect } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/chat/components/output-select/output-select' import type { OutputConfig } from '@/stores/panel/chat/types' @@ -53,7 +53,7 @@ interface ChatDeployProps { type AuthType = 'public' | 'password' | 'email' const getDomainSuffix = (() => { - const suffix = `.${getBaseDomain()}` + const suffix = `.${getEmailDomain()}` return () => suffix })() @@ -772,10 +772,10 @@ export function ChatDeploy({ const port = url.port || (baseDomain.includes(':') ? baseDomain.split(':')[1] : '3000') domainSuffix = `.${baseHost}:${port}` } else { - domainSuffix = `.${getBaseDomain()}` + domainSuffix = `.${getEmailDomain()}` } - const baseDomainForSplit = getBaseDomain() + const baseDomainForSplit = getEmailDomain() const subdomainPart = isDevelopmentUrl ? hostname.split('.')[0] : hostname.split(`.${baseDomainForSplit}`)[0] @@ -1248,7 +1248,7 @@ export function ChatDeploy({ This will permanently delete your chat deployment at{' '} - {subdomain}.{getBaseDomain()} + {subdomain}.{getEmailDomain()} .