Skip to content

An open-source, faster Devin alternative

TypeScript

feat: sandbox webhooks page (Sandboxes section) + Preview labels on agent plane

Igor Zalutski8b96970fabff
diff --git a/cloudflare-workers/api-edge/src/dashboard.ts b/cloudflare-workers/api-edge/src/dashboard.ts
index fdadba1c..87695d84 100644
--- a/cloudflare-workers/api-edge/src/dashboard.ts
+++ b/cloudflare-workers/api-edge/src/dashboard.ts
@@ -25,6 +25,7 @@ import {
syncAutumnToD1,
autumnSetAutoTopup,
} from "./autumn_webhook";
+import { handleWebhooksAPI, type WebhookEnv } from "./webhooks";
export interface DashboardEnv {
OPENCOMPUTER_DB: D1Database;
@@ -872,6 +873,17 @@ export async function handleDashboard(
return proxyToV3(req, env, caller, sub);
}
+ // ── Sandbox lifecycle webhooks ─────────────────────────────────────────
+ // Reuse the public /api/webhooks handler with the cookie-derived org, so the
+ // dashboard manages destinations/deliveries org-scoped without an osb_ key in
+ // the browser. The handler parses the path from the url arg; rewrite it back
+ // to /api/webhooks/*. env carries the Svix bindings at runtime.
+ if (sub === "/webhooks" || sub.startsWith("/webhooks/")) {
+ const whUrl = new URL(req.url);
+ whUrl.pathname = "/api" + sub;
+ return handleWebhooksAPI(req, env as unknown as WebhookEnv, caller, whUrl);
+ }
+
// ── identity / org ─────────────────────────────────────────────────────
if (sub === "/me" && method === "GET") return handleMe(req, env, caller);
if (sub === "/orgs" && method === "GET") return handleListOrgs(req, env, caller);
diff --git a/web/src/App.tsx b/web/src/App.tsx
index e28c872b..a00e5d73 100644
--- a/web/src/App.tsx
+++ b/web/src/App.tsx
@@ -17,6 +17,7 @@ const Templates = lazy(() => import('./pages/Templates'))
const Settings = lazy(() => import('./pages/Settings'))
const Billing = lazy(() => import('./pages/Billing'))
const SandboxDetail = lazy(() => import('./pages/SandboxDetail'))
+const SandboxWebhooks = lazy(() => import('./pages/SandboxWebhooks'))
export default function App() {
return (
@@ -34,6 +35,7 @@ export default function App() {
<Route path="sandboxes/:sandboxId" element={<SandboxDetail />} />
<Route path="checkpoints" element={<Checkpoints />} />
<Route path="templates" element={<Templates />} />
+ <Route path="sandbox-webhooks" element={<SandboxWebhooks />} />
<Route path="api-keys" element={<APIKeys />} />
<Route path="billing" element={<Billing />} />
<Route path="settings" element={<Settings />} />
diff --git a/web/src/api/client.ts b/web/src/api/client.ts
index 8cde9b25..672ada14 100644
--- a/web/src/api/client.ts
+++ b/web/src/api/client.ts
@@ -31,6 +31,8 @@ export type {
Turn,
Destination,
Delivery,
+ SandboxWebhook,
+ SandboxWebhookDelivery,
} from './schemas'
const API_BASE = '/api/dashboard'
@@ -483,3 +485,39 @@ export const redeliver = (id: string, deliveryId: string) =>
apiFetch<void>(`/v3/sessions/${id}/deliveries/${deliveryId}/redeliver`, {
method: 'POST',
})
+
+// ── Sandbox lifecycle webhooks (org-scoped, Svix-backed at the edge) ─────────
+// Reached via /api/dashboard/webhooks* (cookie auth → org), mirroring the public
+// /api/webhooks API.
+export const getSandboxWebhooks = () =>
+ apiFetch('/webhooks', {}, S.SandboxWebhookListSchema).then((r) => r.data)
+
+export const createSandboxWebhook = (body: {
+ url: string
+ eventTypes?: string[]
+ name?: string
+ secret?: string
+}) =>
+ apiFetch(
+ '/webhooks',
+ { method: 'POST', body: JSON.stringify(body) },
+ S.SandboxWebhookSchema,
+ )
+
+export const deleteSandboxWebhook = (id: string) =>
+ apiFetch<void>(`/webhooks/${id}`, { method: 'DELETE' })
+
+export const testSandboxWebhook = (id: string) =>
+ apiFetch<void>(`/webhooks/${id}/test`, { method: 'POST' })
+
+export const getSandboxWebhookDeliveries = (id: string) =>
+ apiFetch(
+ `/webhooks/${id}/deliveries`,
+ {},
+ S.SandboxWebhookDeliveryListSchema,
+ ).then((r) => r.data)
+
+export const redeliverSandboxWebhook = (id: string, deliveryId: string) =>
+ apiFetch<void>(`/webhooks/${id}/deliveries/${deliveryId}/redeliver`, {
+ method: 'POST',
+ })
diff --git a/web/src/api/mock.ts b/web/src/api/mock.ts
index 6e7f4d6a..bb96e485 100644
--- a/web/src/api/mock.ts
+++ b/web/src/api/mock.ts
@@ -527,6 +527,48 @@ const v3deliveries = [
},
]
+const sandboxWebhooks = [
+ {
+ id: 'whk_1',
+ url: 'https://acme.dev/hooks/sandbox',
+ eventTypes: ['sandbox.ready', 'sandbox.stopped'],
+ sandboxId: null,
+ name: 'Prod ingest',
+ enabled: true,
+ hasSecret: true,
+ createdAt: at(3),
+ updatedAt: at(0, 4),
+ },
+ {
+ id: 'whk_2',
+ url: 'https://hooks.internal.acme.dev/all',
+ eventTypes: [],
+ sandboxId: null,
+ name: '',
+ enabled: true,
+ hasSecret: true,
+ createdAt: at(8),
+ updatedAt: at(8),
+ },
+]
+
+const sandboxWebhookDeliveries = [
+ {
+ id: 'msg_1',
+ attemptId: 'att_1',
+ status: 'success',
+ responseStatusCode: 200,
+ timestamp: at(0, 1),
+ },
+ {
+ id: 'msg_2',
+ attemptId: 'att_2',
+ status: 'failed',
+ responseStatusCode: 500,
+ timestamp: at(0, 2),
+ },
+]
+
type Handler = () => unknown
// Ordered most-specific first. Matched against the path (without /api/dashboard).
@@ -558,6 +600,11 @@ const ROUTES: Array<[RegExp, Handler]> = [
[/^\/v3\/sessions\/[^/]+\/deliveries$/, () => ({ data: v3deliveries })],
[/^\/v3\/sessions\/[^/]+$/, () => v3sessions[0]],
[/^\/v3\/sessions(\?.*)?$/, () => ({ data: v3sessions, next_cursor: null })],
+ [
+ /^\/webhooks\/[^/]+\/deliveries$/,
+ () => ({ data: sandboxWebhookDeliveries }),
+ ],
+ [/^\/webhooks$/, () => ({ data: sandboxWebhooks })],
]
export function mockFetch<T>(path: string, options: RequestInit = {}): T {
diff --git a/web/src/api/schemas.ts b/web/src/api/schemas.ts
index bacf9beb..19ae12de 100644
--- a/web/src/api/schemas.ts
+++ b/web/src/api/schemas.ts
@@ -239,6 +239,35 @@ export const SandboxUsageSchema = z.object({
sandboxes: z.array(SandboxUsageRowSchema),
})
+// Sandbox lifecycle webhooks (Svix-backed, served by the edge /api/webhooks*).
+// Org-scoped; shapes mirror the edge's toWire()/listDeliveries() camelCase.
+export const SandboxWebhookSchema = z.object({
+ id: z.string(),
+ url: z.string(),
+ eventTypes: z.array(z.string()).nullish(), // empty/absent = all events
+ sandboxId: z.string().nullish(),
+ name: z.string().nullish(),
+ enabled: z.boolean(),
+ hasSecret: z.boolean().optional(),
+ createdAt: z.string().optional(),
+ updatedAt: z.string().optional(),
+ secret: z.string().optional(), // returned once on create / rotate
+})
+export const SandboxWebhookListSchema = z.object({
+ data: z.array(SandboxWebhookSchema),
+})
+
+export const SandboxWebhookDeliverySchema = z.object({
+ id: z.string(), // message id — the redeliver/get key
+ attemptId: z.string().optional(),
+ status: z.string().optional(), // success | pending | failed
+ responseStatusCode: z.number().nullish(),
+ timestamp: z.string().optional(),
+})
+export const SandboxWebhookDeliveryListSchema = z.object({
+ data: z.array(SandboxWebhookDeliverySchema),
+})
+
// ── Durable Agent Sessions (/v3) ─────────────────────────────────────────────
// Mirrors the sessions-api /v3 contract verbatim (snake_case as the API returns
// it) — no transform layer to keep in sync. Reached via the edge proxy; lenient
@@ -367,3 +396,7 @@ export type AutumnBilling = z.infer<typeof AutumnBillingSchema>
export type StripeInvoice = z.infer<typeof StripeInvoiceSchema>
export type SandboxUsageRow = z.infer<typeof SandboxUsageRowSchema>
export type SandboxUsage = z.infer<typeof SandboxUsageSchema>
+export type SandboxWebhook = z.infer<typeof SandboxWebhookSchema>
+export type SandboxWebhookDelivery = z.infer<
+ typeof SandboxWebhookDeliverySchema
+>
diff --git a/web/src/components/app-shell.tsx b/web/src/components/app-shell.tsx
index be02c951..455e28f6 100644
--- a/web/src/components/app-shell.tsx
+++ b/web/src/components/app-shell.tsx
@@ -8,6 +8,7 @@ import {
Boxes,
Layers,
Package,
+ Webhook,
KeyRound,
CreditCard,
Settings,
@@ -38,7 +39,13 @@ import {
import { ErrorBoundary } from '@/components/error-boundary'
import { cn } from '@/lib/utils'
-type NavItem = { to: string; label: string; icon: LucideIcon; end?: boolean }
+type NavItem = {
+ to: string
+ label: string
+ icon: LucideIcon
+ end?: boolean
+ preview?: boolean
+}
type NavGroup = { label?: string; items: NavItem[] }
// Two planes, subtly separated: the durable-agent plane and the raw-compute
@@ -49,8 +56,13 @@ const NAV: NavGroup[] = [
{
label: 'Agents',
items: [
- { to: '/agents', label: 'Agents', icon: Bot },
- { to: '/sessions', label: 'Sessions', icon: MessagesSquare },
+ { to: '/agents', label: 'Agents', icon: Bot, preview: true },
+ {
+ to: '/sessions',
+ label: 'Sessions',
+ icon: MessagesSquare,
+ preview: true,
+ },
],
},
{
@@ -59,6 +71,7 @@ const NAV: NavGroup[] = [
{ to: '/sandboxes', label: 'Sandboxes', icon: Boxes },
{ to: '/checkpoints', label: 'Checkpoints', icon: Layers },
{ to: '/templates', label: 'Templates', icon: Package },
+ { to: '/sandbox-webhooks', label: 'Webhooks', icon: Webhook },
],
},
{
@@ -175,6 +188,11 @@ function SidebarNav({ onNavigate }: { onNavigate?: () => void }) {
aria-hidden
/>
{item.label}
+ {item.preview ? (
+ <span className="border-border/70 text-muted-foreground ml-auto rounded border px-1 py-px font-sans text-[9px] font-medium tracking-wide uppercase">
+ Preview
+ </span>
+ ) : null}
</NavLink>
))}
</div>
diff --git a/web/src/pages/SandboxWebhooks.tsx b/web/src/pages/SandboxWebhooks.tsx
new file mode 100644
index 00000000..2a076c70
--- /dev/null
+++ b/web/src/pages/SandboxWebhooks.tsx
@@ -0,0 +1,374 @@
+import { useState } from 'react'
+import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
+import { ChevronRight, Plus, RotateCw, Send, Webhook, X } from 'lucide-react'
+import { notifyError } from '@/lib/errors'
+import {
+ getSandboxWebhooks,
+ createSandboxWebhook,
+ deleteSandboxWebhook,
+ testSandboxWebhook,
+ getSandboxWebhookDeliveries,
+ redeliverSandboxWebhook,
+ type SandboxWebhook,
+} from '@/api/client'
+import { PageHeader } from '@/components/page-header'
+import { Panel } from '@/components/panel'
+import { Button } from '@/components/ui/button'
+import {
+ Dialog,
+ DialogContent,
+ DialogDescription,
+ DialogFooter,
+ DialogHeader,
+ DialogTitle,
+} from '@/components/ui/dialog'
+import { Field, Input, Label } from '@/components/form'
+import { Checkbox } from '@/components/ui/checkbox'
+import { StatusBadge } from '@/components/status-badge'
+import { EmptyState } from '@/components/empty-state'
+import { ConfirmDialog } from '@/components/confirm-dialog'
+import { cn } from '@/lib/utils'
+
+// The /v3 event taxonomy's sandbox-plane counterpart (pkg/types/webhook.go).
+// Empty selection = every event.
+const SANDBOX_EVENT_TYPES = [
+ { value: 'sandbox.created', label: 'Created' },
+ { value: 'sandbox.ready', label: 'Ready' },
+ { value: 'sandbox.hibernated', label: 'Hibernated' },
+ { value: 'sandbox.resumed', label: 'Resumed' },
+ { value: 'sandbox.stopped', label: 'Stopped' },
+ { value: 'sandbox.migrated', label: 'Migrated' },
+ { value: 'sandbox.checkpoint.created', label: 'Checkpoint created' },
+ { value: 'sandbox.forked', label: 'Forked' },
+ { value: 'sandbox.scaled', label: 'Scaled' },
+ { value: 'sandbox.preview_url.changed', label: 'Preview URL changed' },
+]
+
+export default function SandboxWebhooks() {
+ const queryClient = useQueryClient()
+ const { data: webhooks, isLoading } = useQuery({
+ queryKey: ['sandbox-webhooks'],
+ queryFn: getSandboxWebhooks,
+ })
+
+ const [showAdd, setShowAdd] = useState(false)
+ const [url, setUrl] = useState('')
+ const [name, setName] = useState('')
+ const [secret, setSecret] = useState('')
+ const [selectedTypes, setSelectedTypes] = useState<Set<string>>(new Set())
+ const [expanded, setExpanded] = useState<Set<string>>(new Set())
+ const [toDelete, setToDelete] = useState<SandboxWebhook | null>(null)
+
+ const toggleType = (v: string) =>
+ setSelectedTypes((prev) => {
+ const next = new Set(prev)
+ if (next.has(v)) next.delete(v)
+ else next.add(v)
+ return next
+ })
+ const toggleExpand = (id: string) =>
+ setExpanded((prev) => {
+ const next = new Set(prev)
+ if (next.has(id)) next.delete(id)
+ else next.add(id)
+ return next
+ })
+
+ const invalidate = () =>
+ void queryClient.invalidateQueries({ queryKey: ['sandbox-webhooks'] })
+
+ const addMutation = useMutation({
+ mutationFn: () =>
+ createSandboxWebhook({
+ url: url.trim(),
+ name: name.trim() || undefined,
+ eventTypes: selectedTypes.size ? Array.from(selectedTypes) : undefined,
+ secret: secret.trim() || undefined,
+ }),
+ onSuccess: () => {
+ setShowAdd(false)
+ setUrl('')
+ setName('')
+ setSecret('')
+ setSelectedTypes(new Set())
+ invalidate()
+ },
+ onError: (e) => notifyError("Couldn't add the destination.", e),
+ })
+ const deleteMutation = useMutation({
+ mutationFn: (id: string) => deleteSandboxWebhook(id),
+ onSettled: invalidate,
+ onError: (e) => notifyError("Couldn't delete the destination.", e),
+ })
+ const testMutation = useMutation({
+ mutationFn: (id: string) => testSandboxWebhook(id),
+ onError: (e) => notifyError("Couldn't send the test event.", e),
+ })
+
+ return (
+ <div>
+ <PageHeader
+ title="Webhooks"
+ description="Deliver sandbox lifecycle events (created, ready, stopped, …) to your endpoints, signed and retried."
+ actions={
+ <Button onClick={() => setShowAdd(true)}>
+ <Plus className="size-4" />
+ Add destination
+ </Button>
+ }
+ />
+
+ <Panel className="overflow-hidden">
+ {isLoading ? (
+ <div className="text-muted-foreground px-4 py-6 text-sm">
+ Loading…
+ </div>
+ ) : (webhooks?.length ?? 0) === 0 ? (
+ <EmptyState
+ icon={Webhook}
+ title="No webhook destinations"
+ description="Add an endpoint to receive sandbox lifecycle events for your org."
+ action={
+ <Button size="sm" onClick={() => setShowAdd(true)}>
+ <Plus className="size-4" />
+ Add destination
+ </Button>
+ }
+ />
+ ) : (
+ <ul className="divide-y">
+ {webhooks?.map((w) => {
+ const isOpen = expanded.has(w.id)
+ return (
+ <li key={w.id}>
+ <div className="flex items-center gap-3 px-4 py-2.5">
+ <button
+ type="button"
+ onClick={() => toggleExpand(w.id)}
+ aria-expanded={isOpen}
+ className="flex min-w-0 flex-1 items-center gap-2 text-left"
+ >
+ <ChevronRight
+ className={cn(
+ 'size-3.5 shrink-0 opacity-60 transition-transform',
+ isOpen && 'rotate-90',
+ )}
+ />
+ <span className="min-w-0 flex-1 truncate">
+ {w.name ? (
+ <span className="text-foreground text-sm font-medium">
+ {w.name}{' '}
+ </span>
+ ) : null}
+ <code className="text-muted-foreground font-mono text-xs">
+ {w.url}
+ </code>
+ </span>
+ </button>
+ <span className="text-muted-foreground hidden text-xs sm:inline">
+ {w.eventTypes?.length
+ ? `${w.eventTypes.length} event${w.eventTypes.length > 1 ? 's' : ''}`
+ : 'All events'}
+ </span>
+ <StatusBadge
+ status={w.enabled ? 'active' : 'paused'}
+ label={w.enabled ? 'Enabled' : 'Paused'}
+ />
+ <Button
+ variant="ghost"
+ size="sm"
+ onClick={() => testMutation.mutate(w.id)}
+ disabled={testMutation.isPending}
+ >
+ <Send className="size-3.5" />
+ Test
+ </Button>
+ <Button
+ variant="ghost"
+ size="icon-sm"
+ aria-label="Delete destination"
+ className="text-muted-foreground hover:text-status-error"
+ onClick={() => setToDelete(w)}
+ >
+ <X className="size-4" />
+ </Button>
+ </div>
+
+ {isOpen ? (
+ <div className="bg-panel-2/40 border-t px-4 py-2 pl-9">
+ {w.eventTypes?.length ? (
+ <p className="text-muted-foreground mb-1.5 font-mono text-[11px]">
+ {w.eventTypes.join(', ')}
+ </p>
+ ) : null}
+ <Deliveries webhookId={w.id} />
+ </div>
+ ) : null}
+ </li>
+ )
+ })}
+ </ul>
+ )}
+ </Panel>
+
+ {/* Add dialog */}
+ <Dialog open={showAdd} onOpenChange={setShowAdd}>
+ <DialogContent>
+ <DialogHeader>
+ <DialogTitle>Add destination</DialogTitle>
+ <DialogDescription>
+ Sandbox lifecycle events for your org are delivered to this HTTPS
+ endpoint, signed with a per-destination secret.
+ </DialogDescription>
+ </DialogHeader>
+ <form
+ className="space-y-4"
+ onSubmit={(e) => {
+ e.preventDefault()
+ if (url.trim()) addMutation.mutate()
+ }}
+ >
+ <Field label="Endpoint URL" htmlFor="swh-url">
+ <Input
+ id="swh-url"
+ value={url}
+ onChange={(e) => setUrl(e.target.value)}
+ placeholder="https://example.com/hooks/sandbox"
+ />
+ </Field>
+ <Field
+ label="Name"
+ htmlFor="swh-name"
+ description="Optional — a label to recognize this destination."
+ >
+ <Input
+ id="swh-name"
+ value={name}
+ onChange={(e) => setName(e.target.value)}
+ placeholder="Prod ingest"
+ />
+ </Field>
+ <div className="space-y-2">
+ <Label>Event types</Label>
+ <p className="text-muted-foreground text-xs">
+ Leave all unchecked to receive every event.
+ </p>
+ <div className="grid grid-cols-2 gap-2 pt-0.5">
+ {SANDBOX_EVENT_TYPES.map((t) => (
+ <label
+ key={t.value}
+ htmlFor={`swh-et-${t.value}`}
+ className="flex cursor-pointer items-center gap-2 text-sm"
+ >
+ <Checkbox
+ id={`swh-et-${t.value}`}
+ checked={selectedTypes.has(t.value)}
+ onCheckedChange={() => toggleType(t.value)}
+ />
+ {t.label}
+ </label>
+ ))}
+ </div>
+ </div>
+ <Field
+ label="Signing secret"
+ htmlFor="swh-secret"
+ description="Optional. Leave blank and one is generated for you."
+ >
+ <Input
+ id="swh-secret"
+ value={secret}
+ onChange={(e) => setSecret(e.target.value)}
+ placeholder="whsec_…"
+ />
+ </Field>
+ <DialogFooter className="mt-2">
+ <Button
+ type="button"
+ variant="ghost"
+ onClick={() => setShowAdd(false)}
+ >
+ Cancel
+ </Button>
+ <Button
+ type="submit"
+ disabled={addMutation.isPending || !url.trim()}
+ >
+ {addMutation.isPending ? 'Adding…' : 'Add destination'}
+ </Button>
+ </DialogFooter>
+ </form>
+ </DialogContent>
+ </Dialog>
+
+ <ConfirmDialog
+ open={toDelete !== null}
+ onOpenChange={(open) => !open && setToDelete(null)}
+ title="Delete this destination?"
+ description="It stops receiving sandbox events. Delivery history is lost. This can't be undone."
+ confirmLabel="Delete destination"
+ destructive
+ pending={deleteMutation.isPending}
+ onConfirm={() => {
+ if (toDelete)
+ deleteMutation.mutate(toDelete.id, {
+ onSuccess: () => setToDelete(null),
+ })
+ }}
+ />
+ </div>
+ )
+}
+
+// Deliveries for one destination — lazy-loaded when its row is expanded.
+function Deliveries({ webhookId }: { webhookId: string }) {
+ const queryClient = useQueryClient()
+ const { data: deliveries, isLoading } = useQuery({
+ queryKey: ['sandbox-webhook-deliveries', webhookId],
+ queryFn: () => getSandboxWebhookDeliveries(webhookId),
+ })
+ const redeliverMutation = useMutation({
+ mutationFn: (deliveryId: string) =>
+ redeliverSandboxWebhook(webhookId, deliveryId),
+ onSettled: () =>
+ void queryClient.invalidateQueries({
+ queryKey: ['sandbox-webhook-deliveries', webhookId],
+ }),
+ onError: (e) => notifyError("Couldn't redeliver.", e),
+ })
+
+ if (isLoading)
+ return <p className="text-muted-foreground py-1 text-xs">Loading…</p>
+ if ((deliveries?.length ?? 0) === 0)
+ return (
+ <p className="text-muted-foreground py-1 text-xs">No deliveries yet.</p>
+ )
+
+ return (
+ <ul className="divide-border/50 divide-y">
+ {deliveries?.map((d) => (
+ <li key={d.id} className="flex items-center gap-3 py-1.5 text-xs">
+ <StatusBadge status={d.status ?? 'pending'} />
+ <span className="text-muted-foreground font-mono">
+ {d.responseStatusCode ?? '—'}
+ </span>
+ <span className="text-muted-foreground truncate">
+ {d.timestamp ? new Date(d.timestamp).toLocaleString() : ''}
+ </span>
+ <span className="flex-1" />
+ {d.status === 'failed' ? (
+ <Button
+ variant="ghost"
+ size="sm"
+ onClick={() => redeliverMutation.mutate(d.id)}
+ disabled={redeliverMutation.isPending}
+ >
+ <RotateCw className="size-3.5" />
+ Redeliver
+ </Button>
+ ) : null}
+ </li>
+ ))}
+ </ul>
+ )
+}
diff --git a/web/vite.config.ts b/web/vite.config.ts
index 78d4c2b8..6ef4d4d0 100644
--- a/web/vite.config.ts
+++ b/web/vite.config.ts
@@ -14,18 +14,28 @@ const target = process.env.OC_API_TARGET || 'http://localhost:8080'
// org-token; this shortcut is local-only.
const v3Key = process.env.OC_V3_KEY
const v3Target = process.env.OC_V3_TARGET || 'https://api.opencomputer.dev'
+const injectKey: ProxyOptions['configure'] = (proxy) => {
+ proxy.on('proxyReq', (proxyReq) => {
+ if (v3Key) proxyReq.setHeader('x-api-key', v3Key)
+ })
+}
+// Both must precede '/api/' below — first matching rule wins.
const v3Proxy: Record<string, ProxyOptions> = v3Key
? {
- // Must precede '/api/' below — first matching rule wins.
+ // /v3 lives at the prod root (/v3/*).
'/api/dashboard/v3': {
target: v3Target,
changeOrigin: true,
rewrite: (p) => p.replace(/^\/api\/dashboard/, ''),
- configure: (proxy) => {
- proxy.on('proxyReq', (proxyReq) => {
- proxyReq.setHeader('x-api-key', v3Key)
- })
- },
+ configure: injectKey,
+ },
+ // Sandbox webhooks live at the prod public API (/api/webhooks/*).
+ '/api/dashboard/webhooks': {
+ target: v3Target,
+ changeOrigin: true,
+ rewrite: (p) =>
+ p.replace(/^\/api\/dashboard\/webhooks/, '/api/webhooks'),
+ configure: injectKey,
},
}
: {}