Skip to content

Commit 121c56b

Browse files
fix(den): make admin backoffice lightweight (anomalyco#888)
* fix(den): lighten admin backoffice delivery Keep the admin panel fast by loading billing status on demand, show clearer upstream failure states, and retry Den deploys once when Render returns a transient update_failed so backend rollouts are less brittle. * chore: drop workflow edit from admin follow-up
1 parent 8db0222 commit 121c56b

4 files changed

Lines changed: 357 additions & 365 deletions

File tree

‎packages/web/app/admin/page.tsx‎

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,15 @@ import { DenAdminPanel } from "../../components/den-admin-panel";
33

44
export default function AdminPage() {
55
return (
6-
<main className="ow-shell">
7-
<div className="ow-ambient" aria-hidden>
8-
<span className="ow-blob ow-blob-one" />
9-
<span className="ow-blob ow-blob-two" />
10-
<span className="ow-blob ow-blob-three" />
11-
</div>
12-
13-
<header className="ow-brand">
14-
<span className="ow-brand-icon" aria-hidden>
15-
<span className="ow-brand-icon-core" />
16-
</span>
17-
<span className="ow-brand-text">OpenWork</span>
18-
</header>
19-
20-
<div className="relative z-10 flex w-full max-w-[92rem] justify-end px-1">
6+
<main className="min-h-screen bg-slate-50 px-4 py-6 sm:px-6 lg:px-8">
7+
<div className="mx-auto flex w-full max-w-6xl flex-wrap items-center justify-between gap-3 pb-5">
8+
<div>
9+
<p className="text-[0.7rem] font-semibold uppercase tracking-[0.18em] text-slate-500">OpenWork</p>
10+
<p className="mt-1 text-sm text-slate-600">Internal Den backoffice</p>
11+
</div>
2112
<Link
2213
href="/"
23-
className="inline-flex items-center justify-center rounded-full border border-slate-200/80 bg-white/85 px-4 py-2 text-sm font-semibold text-slate-700 shadow-[0_10px_24px_rgba(15,23,42,0.06)] backdrop-blur"
14+
className="inline-flex items-center justify-center rounded-full border border-slate-200 bg-white px-4 py-2 text-sm font-semibold text-slate-700"
2415
>
2516
Back to cloud panel
2617
</Link>

‎packages/web/app/api/_lib/upstream-proxy.ts‎

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,31 @@ function isLikelyHtmlBody(body: ArrayBuffer): boolean {
6161
return preview.startsWith("<!doctype") || preview.startsWith("<html") || preview.includes("<body");
6262
}
6363

64-
function shouldFallbackToAuthBase(response: Response, body: ArrayBuffer): boolean {
64+
function isLikelyCannotGetBody(body: ArrayBuffer): boolean {
65+
if (body.byteLength === 0) {
66+
return false;
67+
}
68+
69+
const preview = new TextDecoder().decode(body.slice(0, 256)).trim().toLowerCase();
70+
return preview.includes("cannot get ");
71+
}
72+
73+
function isAdminTargetPath(targetPath: string): boolean {
74+
return targetPath === "v1/admin" || targetPath.startsWith("v1/admin/");
75+
}
76+
77+
function shouldFallbackToAuthBase(response: Response, body: ArrayBuffer, targetPath: string): boolean {
6578
if (response.status === 502 || response.status === 503 || response.status === 504) {
6679
return true;
6780
}
6881

82+
if (response.status === 404 && isAdminTargetPath(targetPath)) {
83+
const contentType = response.headers.get("content-type")?.toLowerCase() ?? "";
84+
if (contentType.includes("text/html") || isLikelyHtmlBody(body) || isLikelyCannotGetBody(body)) {
85+
return true;
86+
}
87+
}
88+
6989
if (response.status < 500) {
7090
return false;
7191
}
@@ -224,7 +244,7 @@ export async function proxyUpstream(
224244
return buildUpstreamErrorResponse(502, "Upstream request failed.");
225245
}
226246

227-
if (apiBase !== authFallbackBase && shouldFallbackToAuthBase(upstream, body)) {
247+
if (apiBase !== authFallbackBase && shouldFallbackToAuthBase(upstream, body, targetPath)) {
228248
try {
229249
const fallback = await fetchUpstream(request, fallbackTargetUrl, contentType, requestBody);
230250
upstream = fallback.response;

0 commit comments

Comments
 (0)