fix(FN-2539): preserve dashboard API compatibility and harden proxy wildcard routing

- Replace app/api.ts with a compatibility barrel that re-exports the legacy client API surface from app/api/legacy.ts
- Move the existing dashboard API implementation into app/api/legacy.ts and update static-analysis tests to include the new module path
- Update proxy wildcard routing to use /proxy/:nodeId/{*splat}, keeping explicit proxy handlers ahead of the fallback route
- Reject proxying to local nodes with a consistent 400 response and expand proxy route tests plus route-ordering compatibility notes
This commit is contained in:
Fusion
2026-04-25 19:56:27 -07:00
committed by gsxdsm
parent 866706308d
commit b0886cdfd4
6 changed files with 7056 additions and 7030 deletions

View File

@@ -226,9 +226,10 @@ export function registerProxyRoutes(ctx: ApiRoutesContext): void {
/**
* Generic wildcard proxy route — forwards any HTTP request to a remote node.
* Keep this after specific /proxy routes so they retain precedence.
* Matches /api/proxy/:nodeId/*
*/
router.all("/proxy/:nodeId/*splat", async (req: Request, res: Response) => {
router.all("/proxy/:nodeId/{*splat}", async (req: Request, res: Response) => {
const nodeId = req.params.nodeId as string;
const splat = req.params.splat as string | string[];
const remainingPath = Array.isArray(splat) ? splat.join("/") : splat;
@@ -245,6 +246,11 @@ export function registerProxyRoutes(ctx: ApiRoutesContext): void {
return;
}
if (node.type === "local") {
res.status(400).json({ error: "Cannot proxy to local node" });
return;
}
if (!node.url) {
res.status(400).json({ error: "Node has no URL" });
return;