Skip to content

Commit 000bec4

Browse files
committed
fix(workflow): derive the webhook URL only where a sub-block shows one
`sub-block.tsx` mounts `useWebhookManagement` for every sub-block in the editor panel, and `getBaseUrl()` throws when NEXT_PUBLIC_APP_URL reads empty, so a missing deployment value took down the whole workflow route instead of the one webhook field. The hook already gates its query and store writes on `useWebhookUrl`; the URL now agrees.
1 parent b96c053 commit 000bec4

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

apps/sim/hooks/use-webhook-management.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,24 @@ export function useWebhookManagement({
100100
useCallback((state) => state.getValue(blockId, 'triggerPath') as string | null, [blockId])
101101
)
102102

103+
/**
104+
* Derived only when the caller actually renders the URL. `getBaseUrl()` throws
105+
* when `NEXT_PUBLIC_APP_URL` is unset, and `sub-block.tsx` mounts this hook for
106+
* every sub-block in the editor panel — deriving the URL unconditionally turns
107+
* a missing deployment value into a render throw for fields that never display
108+
* one, taking down the whole editor instead of the single webhook field.
109+
* Consumers already gate their reads on `useWebhookUrl`.
110+
*/
103111
const webhookUrl = useMemo(() => {
112+
if (!useWebhookUrl) {
113+
return ''
114+
}
104115
const baseUrl = getBaseUrl()
105116
if (!webhookPath) {
106117
return `${baseUrl}/api/webhooks/trigger/${blockId}`
107118
}
108119
return `${baseUrl}/api/webhooks/trigger/${webhookPath}`
109-
}, [webhookPath, blockId])
120+
}, [useWebhookUrl, webhookPath, blockId])
110121

111122
useEffect(() => {
112123
if (triggerId && !isPreview) {

0 commit comments

Comments
 (0)