Skip to content

Add on-demand preview URLs with custom domains#18

Merged
breardon2011 merged 3 commits into
mainfrom
feat/on-demand-preview-urls
Feb 27, 2026
Merged

Add on-demand preview URLs with custom domains#18
breardon2011 merged 3 commits into
mainfrom
feat/on-demand-preview-urls

Conversation

@motatoes

Copy link
Copy Markdown
Contributor

Summary

  • On-demand preview URLs: Sandboxes get custom domain preview URLs (e.g. sb-xxx.openlovable.cc) created explicitly via the SDK, not auto-assigned on creation
  • Cloudflare custom hostnames: Each preview URL registers an individual CF custom hostname for SSL termination and routing
  • Custom domain management: Dashboard UI for orgs to verify and configure their custom domain with DNS verification flow
  • Proxy routing: Both worker-level and control-plane proxies resolve custom hostnames via DB lookup, with Host header rewriting for worker compatibility
  • Full SDK support: TypeScript (createPreviewURL/getPreviewURL/deletePreviewURL) and Python SDK methods

Changes

  • internal/cloudflare/ — new CF API client for custom hostname CRUD and domain verification
  • internal/db/migrations/ — org custom domain columns + sandbox_preview_urls table
  • internal/db/store.go — preview URL CRUD + org domain queries
  • internal/api/sandbox.go — 3 new API endpoints + auto-cleanup on kill
  • internal/api/dashboard.go — custom domain setup + verification polling
  • internal/proxy/ — DB hostname lookup fallback + Host header rewrite in ControlPlaneProxy
  • sdks/typescript/src/sandbox.ts — 3 new SDK methods
  • sdks/python/opencomputer/sandbox.py — 3 new SDK methods
  • web/src/pages/Settings.tsx — custom domain UI with DNS instructions

Test plan

  • E2E tested: create sandbox → start HTTP server → create preview URL → access via custom hostname → delete preview URL → kill sandbox
  • Verified instant activation with domains on Cloudflare DNS (wildcard CNAME)
  • Verified ControlPlaneProxy Host header rewrite routes correctly to workers
  • Verify SSL provisioning for domains on non-CF DNS providers
  • Verify auto-cleanup of CF hostname on sandbox kill

🤖 Generated with Claude Code

Preview URLs are now created explicitly via the SDK (createPreviewURL/
getPreviewURL/deletePreviewURL) rather than auto-assigned on sandbox
creation. Each preview URL registers a Cloudflare custom hostname
(e.g. sb-xxx.openlovable.cc) for per-sandbox routing through the org's
verified custom domain.

Key changes:
- DB migrations for org custom domains and sandbox_preview_urls table
- Cloudflare client for custom hostname CRUD and domain verification
- API endpoints: POST/GET/DELETE /api/sandboxes/:id/preview
- Dashboard UI for custom domain setup with DNS verification flow
- Proxy routing: both SandboxProxy and ControlPlaneProxy resolve
  custom hostnames via DB lookup fallback
- ControlPlaneProxy rewrites Host header to {sandboxID}.{baseDomain}
  so workers can match custom domain requests
- Auto-cleanup of preview URLs on sandbox kill
- TypeScript and Python SDK methods for preview URL management

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@vercel

vercel Bot commented Feb 27, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
opensandbox Ready Ready Preview, Comment Feb 27, 2026 10:49pm

Request Review

@breardon2011 breardon2011 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

approved

motatoes and others added 2 commits February 27, 2026 14:34
Remove automatic domain routing from sandboxes. Preview URLs are now the
only way to get HTTP access, each targeting a specific port. Hostname
format {sandboxID}-p{port}.{baseDomain} lets the proxy parse sandbox ID
and port directly — zero DB lookups on the hot path.

- Add DB migration for port column + unique constraint
- Add ContainerAddr to Manager interface (Podman + Firecracker)
- Rewrite proxy to parse hostname instead of DB lookup
- Add friendly HTML placeholder page for upstream unavailable (auto-refresh)
- Update API handlers: create/list/delete preview URLs by port
- Update dashboard, SDKs (TypeScript + Python), and types

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When an org has a custom domain configured, the dashboard now shows
preview URLs using the custom domain (e.g. sb-xxx-p3000.openlovable.cc)
as the primary link, with a collapsible "Internal URLs" section showing
the base domain URLs underneath.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

@breardon2011 breardon2011 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good

@breardon2011 breardon2011 merged commit 297bfcd into main Feb 27, 2026
3 checks passed
motatoes pushed a commit that referenced this pull request Mar 27, 2026
Add on-demand preview URLs with custom domains
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants