Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/sim/app/api/chat/edit/[id]/route.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ describe('Chat Edit API Route', () => {
}))

vi.doMock('@/lib/urls/utils', () => ({
getBaseDomain: vi.fn().mockReturnValue('localhost:3000'),
getEmailDomain: vi.fn().mockReturnValue('localhost:3000'),
}))

vi.doMock('@/lib/environment', () => ({
Expand Down
6 changes: 3 additions & 3 deletions apps/sim/app/api/chat/edit/[id]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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}`

Expand Down Expand Up @@ -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}`

Expand Down
6 changes: 5 additions & 1 deletion apps/sim/app/api/chat/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -53,7 +53,7 @@ interface ChatDeployProps {
type AuthType = 'public' | 'password' | 'email'

const getDomainSuffix = (() => {
const suffix = `.${getBaseDomain()}`
const suffix = `.${getEmailDomain()}`
return () => suffix
})()

Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -1248,7 +1248,7 @@ export function ChatDeploy({
<AlertDialogDescription>
This will permanently delete your chat deployment at{' '}
<span className='font-mono text-destructive'>
{subdomain}.{getBaseDomain()}
{subdomain}.{getEmailDomain()}
</span>
.
<p className='mt-2'>
Expand Down