Merge pull request #234 from JakobStadlhuber/feat/webhook-self-hosted
Add support for Self-Hosted Webhook URL Usage and added project_id into the webhook payload
This commit is contained in:
commit
1a16378fe8
@ -50,3 +50,6 @@ PROXY_USERNAME=
|
||||
PROXY_PASSWORD=
|
||||
# set if you'd like to block media requests to save proxy bandwidth
|
||||
BLOCK_MEDIA=
|
||||
|
||||
# Set this to the URL of your webhook when using the self-hosted version of FireCrawl
|
||||
SELF_HOSTED_WEBHOOK_URL=
|
@ -2,6 +2,10 @@ import { supabase_service } from "./supabase";
|
||||
|
||||
export const callWebhook = async (teamId: string, data: any) => {
|
||||
try {
|
||||
const selfHostedUrl = process.env.SELF_HOSTED_WEBHOOK_URL;
|
||||
let webhookUrl = selfHostedUrl;
|
||||
|
||||
if (!selfHostedUrl) {
|
||||
const { data: webhooksData, error } = await supabase_service
|
||||
.from('webhooks')
|
||||
.select('url')
|
||||
@ -17,6 +21,9 @@ export const callWebhook = async (teamId: string, data: any) => {
|
||||
return null;
|
||||
}
|
||||
|
||||
webhookUrl = webhooksData[0].url;
|
||||
}
|
||||
|
||||
let dataToSend = [];
|
||||
if (data.result.links && data.result.links.length !== 0) {
|
||||
for (let i = 0; i < data.result.links.length; i++) {
|
||||
@ -28,13 +35,14 @@ export const callWebhook = async (teamId: string, data: any) => {
|
||||
}
|
||||
}
|
||||
|
||||
await fetch(webhooksData[0].url, {
|
||||
await fetch(webhookUrl, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({
|
||||
success: data.success,
|
||||
project_id: data.project_id,
|
||||
data: dataToSend,
|
||||
error: data.error || undefined,
|
||||
}),
|
||||
|
Loading…
Reference in New Issue
Block a user