Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added .codex
Empty file.
16 changes: 12 additions & 4 deletions api/edb/[...path].ts → api/edb-proxy.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { VercelRequest, VercelResponse } from "@vercel/node";
import { maybeInjectDefaultEtherscanKey } from "../edbShared.js";
import { maybeInjectDefaultEtherscanKey } from "./edbShared.js";

export const config = {
api: { bodyParser: false },
Expand Down Expand Up @@ -104,9 +104,17 @@ export default async function handler(req: VercelRequest, res: VercelResponse) {
return res.status(405).json({ error: "method_not_allowed" });
}

// Extract sub-path from URL — more reliable than req.query.path across Vercel runtimes
const urlPath = (req.url || "").split("?")[0];
const subPath = urlPath.replace(/^\/api\/edb\/?/, "");
// Extract sub-path from the `path` query param populated by the Vercel
// rewrite rule in vercel.json. Vercel's file-based catch-all routing
// (`api/edb/[...path].ts`) does not reliably match multi-segment requests
// under `/api/edb/*` on this project, so we route via an explicit rewrite
// that mirrors the lifi-composer pattern.
const pathParam = req.query?.path;
const subPath = Array.isArray(pathParam)
? pathParam.join("/")
: typeof pathParam === "string"
? pathParam
: "";

// Validate each path segment
const parts = subPath ? subPath.split("/") : [];
Expand Down
Loading