Files
openshell_controller/app/api/openshell/dashboard/proxy/route.ts
T
Mark McKeen 4de15bc8ab 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
2026-03-29 09:59:15 -06:00

36 lines
1005 B
TypeScript

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 })
}
}