Proxy API through Next.js route handlers — eliminates CORS

This commit is contained in:
Hermes
2026-04-09 20:54:13 -05:00
parent 517583d1c4
commit 1bce2a29cc
6 changed files with 81 additions and 3 deletions
+16
View File
@@ -0,0 +1,16 @@
import { NextResponse } from "next/server";
const BACKEND = process.env.HERMES_BACKEND_URL || "http://127.0.0.1:8643";
export async function GET() {
try {
const res = await fetch(`${BACKEND}/health`);
const data = await res.text();
return new NextResponse(data, {
status: res.status,
headers: { "content-type": "application/json" },
});
} catch {
return NextResponse.json({ status: "error" }, { status: 502 });
}
}