Skip to content

An open-source, faster Devin alternative

TypeScript

Show custom domain preview URLs in dashboard with internal URL toggle

motatoes0cd8155b84d2
diff --git a/internal/api/dashboard.go b/internal/api/dashboard.go
index b15940bb..4497ed98 100644
--- a/internal/api/dashboard.go
+++ b/internal/api/dashboard.go
@@ -578,10 +578,37 @@ func (s *Server) dashboardGetSession(c echo.Context) error {
}
}
- // Include preview URLs
+ // Include preview URLs — add custom domain hostname if the org has one
urls, err := s.store.ListPreviewURLs(c.Request().Context(), sandboxID)
if err == nil && len(urls) > 0 {
- resp["previewUrls"] = urls
+ var customDomain string
+ org, orgErr := s.store.GetOrg(c.Request().Context(), orgID)
+ if orgErr == nil && org.CustomDomain != nil && *org.CustomDomain != "" {
+ customDomain = *org.CustomDomain
+ }
+
+ urlMaps := make([]map[string]interface{}, len(urls))
+ for i, u := range urls {
+ urlMaps[i] = map[string]interface{}{
+ "id": u.ID,
+ "sandboxId": u.SandboxID,
+ "orgId": u.OrgID,
+ "hostname": u.Hostname,
+ "port": u.Port,
+ "sslStatus": u.SSLStatus,
+ "authConfig": u.AuthConfig,
+ "createdAt": u.CreatedAt,
+ }
+ if u.CFHostnameID != nil {
+ urlMaps[i]["cfHostnameId"] = *u.CFHostnameID
+ }
+ if customDomain != "" {
+ if dot := strings.Index(u.Hostname, "."); dot > 0 {
+ urlMaps[i]["customHostname"] = u.Hostname[:dot+1] + customDomain
+ }
+ }
+ }
+ resp["previewUrls"] = urlMaps
} else {
resp["previewUrls"] = []interface{}{}
}
diff --git a/web/src/api/client.ts b/web/src/api/client.ts
index feb7a39f..afba6969 100644
--- a/web/src/api/client.ts
+++ b/web/src/api/client.ts
@@ -123,6 +123,7 @@ export interface PreviewURL {
sandboxId: string
orgId: string
hostname: string
+ customHostname?: string
port: number
cfHostnameId?: string
sslStatus: string
diff --git a/web/src/pages/SessionDetail.tsx b/web/src/pages/SessionDetail.tsx
index edb57838..c1fd5606 100644
--- a/web/src/pages/SessionDetail.tsx
+++ b/web/src/pages/SessionDetail.tsx
@@ -59,8 +59,9 @@ function StatCard({ label, value, sub }: { label: string; value: string; sub?: s
export default function SessionDetail() {
const { sandboxId } = useParams<{ sandboxId: string }>()
const navigate = useNavigate()
- const [copiedPort, setCopiedPort] = useState<number | null>(null)
+ const [copiedUrl, setCopiedUrl] = useState<string | null>(null)
const [showTerminal, setShowTerminal] = useState(false)
+ const [showInternal, setShowInternal] = useState(false)
const { data: session, isLoading } = useQuery({
queryKey: ['session-detail', sandboxId],
@@ -76,10 +77,10 @@ export default function SessionDetail() {
retry: false,
})
- const copyUrl = (hostname: string, port: number) => {
+ const copyUrl = (hostname: string, key: string) => {
navigator.clipboard.writeText(`https://${hostname}`)
- setCopiedPort(port)
- setTimeout(() => setCopiedPort(null), 2000)
+ setCopiedUrl(key)
+ setTimeout(() => setCopiedUrl(null), 2000)
}
if (isLoading) {
@@ -185,50 +186,108 @@ export default function SessionDetail() {
)}
{/* Preview URLs */}
- {session.previewUrls && session.previewUrls.length > 0 && (
- <div className="glass-card animate-in stagger-2" style={{ padding: 20, marginBottom: 16 }}>
- <div style={{ fontSize: 11, fontWeight: 600, color: 'var(--text-tertiary)', textTransform: 'uppercase', letterSpacing: '0.05em', marginBottom: 10 }}>
- Preview URLs
- </div>
- <div style={{ display: 'flex', flexDirection: 'column', gap: 8 }}>
- {session.previewUrls.map((url) => (
- <div key={url.id} style={{ display: 'flex', alignItems: 'center', gap: 10 }}>
- <div style={{
- minWidth: 60,
- fontSize: 12,
- fontWeight: 600,
- color: 'var(--text-tertiary)',
- fontFamily: 'var(--font-mono)',
- }}>
- :{url.port}
- </div>
- <div style={{
- flex: 1,
- background: 'var(--bg-deep)',
- border: '1px solid var(--border-subtle)',
- borderRadius: 'var(--radius-sm)',
- padding: '10px 14px',
- fontFamily: 'var(--font-mono)',
- fontSize: 13,
- color: 'var(--text-accent)',
- }}>
- <a
- href={`https://${url.hostname}`}
- target="_blank"
- rel="noopener noreferrer"
- style={{ color: 'var(--text-accent)', textDecoration: 'none' }}
- >
- https://{url.hostname}
- </a>
- </div>
- <button className="btn-ghost" onClick={() => copyUrl(url.hostname, url.port)} style={{ whiteSpace: 'nowrap' }}>
- {copiedPort === url.port ? 'Copied' : 'Copy'}
+ {session.previewUrls && session.previewUrls.length > 0 && (() => {
+ const hasCustom = session.previewUrls.some(u => u.customHostname)
+ return (
+ <div className="glass-card animate-in stagger-2" style={{ padding: 20, marginBottom: 16 }}>
+ <div style={{ fontSize: 11, fontWeight: 600, color: 'var(--text-tertiary)', textTransform: 'uppercase', letterSpacing: '0.05em', marginBottom: 10 }}>
+ Preview URLs
+ </div>
+ <div style={{ display: 'flex', flexDirection: 'column', gap: 8 }}>
+ {session.previewUrls.map((url) => {
+ const displayHost = url.customHostname || url.hostname
+ return (
+ <div key={url.id} style={{ display: 'flex', alignItems: 'center', gap: 10 }}>
+ <div style={{
+ minWidth: 60,
+ fontSize: 12,
+ fontWeight: 600,
+ color: 'var(--text-tertiary)',
+ fontFamily: 'var(--font-mono)',
+ }}>
+ :{url.port}
+ </div>
+ <div style={{
+ flex: 1,
+ background: 'var(--bg-deep)',
+ border: '1px solid var(--border-subtle)',
+ borderRadius: 'var(--radius-sm)',
+ padding: '10px 14px',
+ fontFamily: 'var(--font-mono)',
+ fontSize: 13,
+ color: 'var(--text-accent)',
+ }}>
+ <a
+ href={`https://${displayHost}`}
+ target="_blank"
+ rel="noopener noreferrer"
+ style={{ color: 'var(--text-accent)', textDecoration: 'none' }}
+ >
+ https://{displayHost}
+ </a>
+ </div>
+ <button className="btn-ghost" onClick={() => copyUrl(displayHost, `${url.port}`)} style={{ whiteSpace: 'nowrap' }}>
+ {copiedUrl === `${url.port}` ? 'Copied' : 'Copy'}
+ </button>
+ </div>
+ )
+ })}
+ </div>
+
+ {/* Internal URLs toggle — only shown when custom domain URLs are displayed */}
+ {hasCustom && (
+ <div style={{ marginTop: 12 }}>
+ <button
+ onClick={() => setShowInternal(!showInternal)}
+ style={{
+ background: 'none', border: 'none', cursor: 'pointer', padding: 0,
+ fontSize: 11, color: 'var(--text-tertiary)', display: 'flex', alignItems: 'center', gap: 4,
+ }}
+ >
+ <svg width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"
+ style={{ transform: showInternal ? 'rotate(90deg)' : 'none', transition: 'transform 0.15s' }}>
+ <polyline points="9 18 15 12 9 6" />
+ </svg>
+ Internal URLs
</button>
+ {showInternal && (
+ <div style={{ display: 'flex', flexDirection: 'column', gap: 6, marginTop: 8 }}>
+ {session.previewUrls.map((url) => (
+ <div key={`int-${url.id}`} style={{ display: 'flex', alignItems: 'center', gap: 10 }}>
+ <div style={{ minWidth: 60, fontSize: 11, color: 'var(--text-tertiary)', fontFamily: 'var(--font-mono)' }}>
+ :{url.port}
+ </div>
+ <div style={{
+ flex: 1,
+ background: 'var(--bg-deep)',
+ border: '1px solid var(--border-subtle)',
+ borderRadius: 'var(--radius-sm)',
+ padding: '8px 12px',
+ fontFamily: 'var(--font-mono)',
+ fontSize: 12,
+ color: 'var(--text-tertiary)',
+ }}>
+ <a
+ href={`https://${url.hostname}`}
+ target="_blank"
+ rel="noopener noreferrer"
+ style={{ color: 'var(--text-tertiary)', textDecoration: 'none' }}
+ >
+ https://{url.hostname}
+ </a>
+ </div>
+ <button className="btn-ghost" onClick={() => copyUrl(url.hostname, `int-${url.port}`)} style={{ whiteSpace: 'nowrap', fontSize: 11 }}>
+ {copiedUrl === `int-${url.port}` ? 'Copied' : 'Copy'}
+ </button>
+ </div>
+ ))}
+ </div>
+ )}
</div>
- ))}
+ )}
</div>
- </div>
- )}
+ )
+ })()}
{/* Details */}
<div className="glass-card animate-in stagger-3" style={{ padding: 20, marginBottom: 16 }}>