Skip to content

Commit 0dd7735

Browse files
authored
v0.3.9: chat deploy
2 parents d783ba6 + 8ddc1d8 commit 0dd7735

File tree

4 files changed

+14
-10
lines changed

4 files changed

+14
-10
lines changed

apps/sim/app/api/chat/edit/[id]/route.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ describe('Chat Edit API Route', () => {
7171
}))
7272

7373
vi.doMock('@/lib/urls/utils', () => ({
74-
getBaseDomain: vi.fn().mockReturnValue('localhost:3000'),
74+
getEmailDomain: vi.fn().mockReturnValue('localhost:3000'),
7575
}))
7676

7777
vi.doMock('@/lib/environment', () => ({

apps/sim/app/api/chat/edit/[id]/route.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { z } from 'zod'
44
import { getSession } from '@/lib/auth'
55
import { isDev } from '@/lib/environment'
66
import { createLogger } from '@/lib/logs/console-logger'
7-
import { getBaseDomain } from '@/lib/urls/utils'
7+
import { getEmailDomain } from '@/lib/urls/utils'
88
import { encryptSecret } from '@/lib/utils'
99
import { checkChatAccess } from '@/app/api/chat/utils'
1010
import { createErrorResponse, createSuccessResponse } from '@/app/api/workflows/utils'
@@ -68,7 +68,7 @@ export async function GET(_request: NextRequest, { params }: { params: Promise<{
6868
// Create a new result object without the password
6969
const { password, ...safeData } = chatRecord
7070

71-
const baseDomain = getBaseDomain()
71+
const baseDomain = getEmailDomain()
7272
const protocol = isDev ? 'http' : 'https'
7373
const chatUrl = `${protocol}://${chatRecord.subdomain}.${baseDomain}`
7474

@@ -214,7 +214,7 @@ export async function PATCH(request: NextRequest, { params }: { params: Promise<
214214

215215
const updatedSubdomain = subdomain || existingChat[0].subdomain
216216

217-
const baseDomain = getBaseDomain()
217+
const baseDomain = getEmailDomain()
218218
const protocol = isDev ? 'http' : 'https'
219219
const chatUrl = `${protocol}://${updatedSubdomain}.${baseDomain}`
220220

apps/sim/app/api/chat/route.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,11 @@ export async function POST(request: NextRequest) {
175175
let chatUrl: string
176176
try {
177177
const url = new URL(baseUrl)
178-
chatUrl = `${url.protocol}//${subdomain}.${url.host}`
178+
let host = url.host
179+
if (host.startsWith('www.')) {
180+
host = host.substring(4)
181+
}
182+
chatUrl = `${url.protocol}//${subdomain}.${host}`
179183
} catch (error) {
180184
logger.warn('Failed to parse baseUrl, falling back to defaults:', {
181185
baseUrl,

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/control-bar/components/deploy-modal/components/chat-deploy/chat-deploy.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import { Label } from '@/components/ui/label'
3131
import { Skeleton } from '@/components/ui/skeleton'
3232
import { Textarea } from '@/components/ui/textarea'
3333
import { createLogger } from '@/lib/logs/console-logger'
34-
import { getBaseDomain } from '@/lib/urls/utils'
34+
import { getBaseDomain, getEmailDomain } from '@/lib/urls/utils'
3535
import { cn } from '@/lib/utils'
3636
import { OutputSelect } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/chat/components/output-select/output-select'
3737
import type { OutputConfig } from '@/stores/panel/chat/types'
@@ -53,7 +53,7 @@ interface ChatDeployProps {
5353
type AuthType = 'public' | 'password' | 'email'
5454

5555
const getDomainSuffix = (() => {
56-
const suffix = `.${getBaseDomain()}`
56+
const suffix = `.${getEmailDomain()}`
5757
return () => suffix
5858
})()
5959

@@ -772,10 +772,10 @@ export function ChatDeploy({
772772
const port = url.port || (baseDomain.includes(':') ? baseDomain.split(':')[1] : '3000')
773773
domainSuffix = `.${baseHost}:${port}`
774774
} else {
775-
domainSuffix = `.${getBaseDomain()}`
775+
domainSuffix = `.${getEmailDomain()}`
776776
}
777777

778-
const baseDomainForSplit = getBaseDomain()
778+
const baseDomainForSplit = getEmailDomain()
779779
const subdomainPart = isDevelopmentUrl
780780
? hostname.split('.')[0]
781781
: hostname.split(`.${baseDomainForSplit}`)[0]
@@ -1248,7 +1248,7 @@ export function ChatDeploy({
12481248
<AlertDialogDescription>
12491249
This will permanently delete your chat deployment at{' '}
12501250
<span className='font-mono text-destructive'>
1251-
{subdomain}.{getBaseDomain()}
1251+
{subdomain}.{getEmailDomain()}
12521252
</span>
12531253
.
12541254
<p className='mt-2'>

0 commit comments

Comments
 (0)