Skip to content

Commit 51b110d

Browse files
fixes
1 parent 23a92d2 commit 51b110d

6 files changed

Lines changed: 16 additions & 58 deletions

File tree

src/app/api/health/[instanceId]/route.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,6 @@ import { requireAuth } from '@/lib/auth'
33
import { supabaseAdmin } from '@/lib/supabase/admin'
44
import { checkInstanceHealth } from '@/lib/openclaw/health'
55

6-
async function isDashboardReachable(url: string): Promise<boolean> {
7-
try {
8-
await fetch(url, { method: 'HEAD', signal: AbortSignal.timeout(4000), redirect: 'follow' })
9-
return true
10-
} catch {
11-
return false
12-
}
13-
}
14-
156
export async function GET(
167
_req: Request,
178
{ params }: { params: Promise<{ instanceId: string }> }
@@ -45,13 +36,6 @@ export async function GET(
4536
updates.provisioned_at = new Date().toISOString()
4637
}
4738

48-
if (instance.dashboard_url) {
49-
const reachable = await isDashboardReachable(instance.dashboard_url)
50-
if (!reachable) {
51-
updates.dashboard_url = null
52-
}
53-
}
54-
5539
await supabaseAdmin
5640
.from('instances')
5741
.update(updates)

src/components/instances/instance-dashboard.tsx

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,14 @@
33
import { ExternalLink, LoaderCircle } from 'lucide-react'
44
import { useState } from 'react'
55
import { buttonVariants } from '@/components/ui/button'
6-
import { usePolling } from '@/hooks/use-polling'
76
import type { Instance } from '@/types/instance'
87

9-
function buildDashboardUrl(base: string, token: string | null): string {
10-
return token ? `${base}/#token=${token}` : base
11-
}
12-
13-
export function InstanceDashboard({ instance: initial }: { instance: Instance }) {
14-
const { data: polledInstance } = usePolling<{ instance: Instance }>(
15-
`/api/instances/${initial.id}`,
16-
10000,
17-
)
18-
const instance = polledInstance?.instance ?? initial
19-
20-
usePolling<unknown>(
21-
instance.ip_address ? `/api/health/${instance.id}` : null,
22-
15000,
23-
)
24-
25-
const baseUrl = instance.dashboard_url
26-
?? (instance.ip_address ? `http://${instance.ip_address}` : null)
8+
export function InstanceDashboard({ instance }: { instance: Instance }) {
9+
const baseUrl = instance.dashboard_url ?? (instance.ip_address ? `http://${instance.ip_address}` : null)
2710
const dashboardUrl = baseUrl
28-
? buildDashboardUrl(baseUrl, instance.gateway_token)
11+
? instance.gateway_token
12+
? `${baseUrl}/#token=${instance.gateway_token}`
13+
: baseUrl
2914
: null
3015

3116
const [loaded, setLoaded] = useState(false)

src/components/instances/instance-terminal-workspace.tsx

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { useState } from 'react'
44
import { ExternalLink, LoaderCircle, Plus, RefreshCw, TerminalSquare, X } from 'lucide-react'
55
import { cn } from '@/lib/utils'
66
import { getInstanceTerminalConnection } from '@/lib/terminal'
7-
import { usePolling } from '@/hooks/use-polling'
87
import type { Instance } from '@/types/instance'
98

109
interface InstanceTerminalWorkspaceProps {
@@ -23,20 +22,9 @@ function createSession(index: number): TerminalSession {
2322
}
2423

2524
export function InstanceTerminalWorkspace({
26-
instance: initial,
25+
instance,
2726
className,
2827
}: InstanceTerminalWorkspaceProps) {
29-
const { data: polledInstance } = usePolling<{ instance: Instance }>(
30-
`/api/instances/${initial.id}`,
31-
10000,
32-
)
33-
const instance = polledInstance?.instance ?? initial
34-
35-
usePolling<unknown>(
36-
instance.ip_address ? `/api/health/${instance.id}` : null,
37-
15000,
38-
)
39-
4028
const connection = getInstanceTerminalConnection(instance)
4129
const [sessions, setSessions] = useState<TerminalSession[]>([createSession(1)])
4230
const [activeSessionId, setActiveSessionId] = useState('terminal-1')
@@ -198,7 +186,7 @@ export function InstanceTerminalWorkspace({
198186
)}
199187

200188
<iframe
201-
key={`${session.id}:${session.version}:${terminalUrl}`}
189+
key={`${session.id}:${session.version}`}
202190
src={terminalUrl}
203191
title={session.title}
204192
className="block h-full w-full"

src/lib/dns/cloudflare.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ describe('cloudflare dns helpers', () => {
6060
type: 'A',
6161
name: 'demo.example.com',
6262
content: '1.2.3.4',
63-
ttl: 60,
64-
proxied: false,
63+
ttl: 1,
64+
proxied: true,
6565
})
6666
})
6767

@@ -80,7 +80,7 @@ describe('cloudflare dns helpers', () => {
8080

8181
expect(JSON.parse(mockFetch.mock.calls[0][1].body as string)).toEqual(
8282
expect.objectContaining({
83-
name: 'demo.clawcloud.dev',
83+
name: 'demo.agentcomputers.app',
8484
})
8585
)
8686
})

src/lib/dns/cloudflare.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ export async function createDnsRecord(
2727
type: 'A',
2828
name,
2929
content: ip,
30-
ttl: 60,
31-
proxied: false,
30+
ttl: 1,
31+
proxied: true,
3232
}),
3333
})
3434

src/lib/hetzner/cloud-init.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ CUSTOMER_ID=${params.customerId}
2525
`
2626
}
2727

28-
function buildCaddyfile(hostname: string): string {
28+
function buildCaddyfile(): string {
2929
const routes = ` handle /gateway/* {
3030
uri strip_prefix /gateway
3131
reverse_proxy localhost:18789
@@ -41,7 +41,8 @@ function buildCaddyfile(hostname: string): string {
4141
-Content-Security-Policy
4242
}`
4343

44-
return `${hostname} {
44+
return `:443 {
45+
tls internal
4546
${routes}
4647
}
4748
@@ -94,7 +95,7 @@ export function generateCloudInit(params: CloudInitParams): string {
9495
const envFile = b64(buildEnvFile(params))
9596
const openclawEnv = b64(buildOpenClawEnv(params))
9697
const configFile = b64(params.openclawConfig)
97-
const caddyFile = b64(buildCaddyfile(hostname))
98+
const caddyFile = b64(buildCaddyfile())
9899
const ttydService = b64(buildTtydService())
99100
const gatewayService = b64(buildGatewayService())
100101

0 commit comments

Comments
 (0)