fx-chartingDocs
Webhooks

Send from your server (onWebhook)

Deliver every webhook through your own API route: no CORS limits, secrets stay on the server.

app/components/Chart.js
"use client";
import { FxChart } from "@fx-charting/max";

export function Chart() {
  return (
    <FxChart
      onWebhook={({ url, body }) =>
        fetch("/api/webhook", { method: "POST", body: JSON.stringify({ url, body }) }).then((r) => ({ ok: r.ok }))
      }
    />
  );
}
app/api/webhook/route.js
export async function POST(req) {
  const { url, body } = await req.json();
  // Optional: only allow your own destinations, add auth headers, log…
  const r = await fetch(url, { method: "POST", headers: { "Content-Type": "application/json" }, body });
  return Response.json({ ok: r.ok }, { status: r.ok ? 200 : 502 });
}

onWebhook receives { url, body, json } (json = the parsed body) and returns { ok }; the result shows in the delivery log.