Skip to content

Commit 65f4b1e

Browse files
iamjr15claude
andcommitted
feat: add Cloudflare Workers preview proxy for Daytona
- Add preview-worker using Cloudflare Workers to proxy Daytona sandbox previews - Removes the Daytona preview warning page by adding X-Daytona-Skip-Preview-Warning header - Update backend to use https://preview.trycheatcode.com as preview URL - DNS configured via Vercel pointing to cheatcode-preview-proxy.trycheatcode.workers.dev 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 6fd4106 commit 65f4b1e

File tree

7 files changed

+1799
-3
lines changed

7 files changed

+1799
-3
lines changed

backend/sandbox/api.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
import re
23
import urllib.parse
34
from typing import Optional
45
import time
@@ -15,6 +16,9 @@
1516
from utils.auth_utils import get_optional_user_id
1617
from services.supabase import DBConnection
1718

19+
# Preview proxy URL - removes Daytona warning page
20+
PREVIEW_PROXY_URL = os.environ.get('PREVIEW_PROXY_URL', 'https://preview.trycheatcode.com')
21+
1822
# Initialize shared resources
1923
router = APIRouter(tags=["sandbox"])
2024
db = None
@@ -1039,10 +1043,22 @@ async def get_sandbox_preview_url(
10391043
# Get the Daytona preview link for the appropriate port
10401044
try:
10411045
preview_info = await sandbox.get_preview_link(port)
1042-
url = preview_info.url if hasattr(preview_info, 'url') else str(preview_info)
1043-
1046+
daytona_url = preview_info.url if hasattr(preview_info, 'url') else str(preview_info)
1047+
1048+
# Transform Daytona URL to use our proxy (removes warning page)
1049+
# Original: https://3000-abc123-def456.proxy.daytona.works/
1050+
# Proxied: https://preview-proxy.../3000-abc123-def456/
1051+
proxy_url = daytona_url
1052+
if PREVIEW_PROXY_URL:
1053+
match = re.match(r'https?://(\d+-[a-f0-9-]+)\.proxy\.daytona\.works(/.*)?', daytona_url, re.IGNORECASE)
1054+
if match:
1055+
port_sandbox = match.group(1) # e.g., "3000-abc123-def456"
1056+
path = match.group(2) or '/'
1057+
proxy_url = f"{PREVIEW_PROXY_URL}/{port_sandbox}{path}"
1058+
logger.info(f"Transformed preview URL: {daytona_url} -> {proxy_url}")
1059+
10441060
return {
1045-
"preview_url": url,
1061+
"preview_url": proxy_url,
10461062
"status": "available"
10471063
}
10481064

preview-worker/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules/
2+
dist/
3+
.wrangler/
4+
.dev.vars

0 commit comments

Comments
 (0)