feat: proxy loopback-only OpenClaw dashboard through web UI
- add dashboard proxy route for local OpenClaw endpoint - return proxiedUrl from dashboard open API - update sandbox button to open proxied route in new tab
This commit is contained in:
@@ -6,8 +6,9 @@ export async function GET() {
|
||||
return NextResponse.json({
|
||||
ok: true,
|
||||
dashboardUrl,
|
||||
proxiedUrl: '/api/openshell/dashboard/proxy',
|
||||
openInNewTab: true,
|
||||
loopbackOnly: true,
|
||||
note: 'OpenClaw Dashboard is loopback-only on the host. For remote browser access, add a reverse proxy route or rebind the gateway.'
|
||||
note: 'OpenClaw Dashboard is loopback-only on the host, so the web UI uses a local proxy route to expose it.'
|
||||
})
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
import { NextResponse } from 'next/server'
|
||||
|
||||
const OPENCLAW_LOCAL_DASHBOARD = 'http://127.0.0.1:18789/'
|
||||
|
||||
export async function GET(request: Request) {
|
||||
try {
|
||||
const url = new URL(request.url)
|
||||
const targetPath = url.searchParams.get('path') || ''
|
||||
const target = new URL(targetPath, OPENCLAW_LOCAL_DASHBOARD)
|
||||
|
||||
const upstream = await fetch(target.toString(), {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
accept: 'text/html,application/json;q=0.9,*/*;q=0.8'
|
||||
},
|
||||
cache: 'no-store'
|
||||
})
|
||||
|
||||
const contentType = upstream.headers.get('content-type') || 'text/html; charset=utf-8'
|
||||
const body = await upstream.text()
|
||||
|
||||
return new NextResponse(body, {
|
||||
status: upstream.status,
|
||||
headers: {
|
||||
'content-type': contentType,
|
||||
'cache-control': 'no-store'
|
||||
}
|
||||
})
|
||||
} catch (error) {
|
||||
return NextResponse.json({
|
||||
ok: false,
|
||||
error: error instanceof Error ? error.message : 'Failed to proxy OpenClaw dashboard'
|
||||
}, { status: 500 })
|
||||
}
|
||||
}
|
||||
@@ -181,9 +181,11 @@ export default function SandboxList({
|
||||
const res = await fetch('/api/openshell/dashboard/open')
|
||||
const data = await res.json()
|
||||
setDashboardMessage(data.loopbackOnly
|
||||
? `OpenClaw Dashboard detected at ${data.dashboardUrl}. It is loopback-only, so the next step is adding a proxy/open-in-new-tab bridge.`
|
||||
? `OpenClaw Dashboard detected at ${data.dashboardUrl}. Opening proxied dashboard route.`
|
||||
: `OpenClaw Dashboard: ${data.dashboardUrl}`)
|
||||
if (data.dashboardUrl && !data.loopbackOnly) {
|
||||
if (data.proxiedUrl) {
|
||||
window.open(data.proxiedUrl, '_blank', 'noopener,noreferrer')
|
||||
} else if (data.dashboardUrl && !data.loopbackOnly) {
|
||||
window.open(data.dashboardUrl, '_blank', 'noopener,noreferrer')
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user