Stabilize dashboard runtime proxy

This commit is contained in:
Codex
2026-04-24 13:47:10 +00:00
parent 4d15ce4388
commit 05db76d930
39 changed files with 4349 additions and 1472 deletions
+3 -29
View File
@@ -1,35 +1,9 @@
import { NextResponse } from 'next/server'
const OPENCLAW_LOCAL_DASHBOARD = 'http://127.0.0.1:18789/'
import { proxyErrorResponse, proxyOpenClawDashboard } from './shared'
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'
}
})
return await proxyOpenClawDashboard(request)
} catch (error) {
return NextResponse.json({
ok: false,
error: error instanceof Error ? error.message : 'Failed to proxy OpenClaw dashboard'
}, { status: 500 })
return proxyErrorResponse(error)
}
}