From 97a8778449a3153d049882ee17c1a8fcc5ce2e4a Mon Sep 17 00:00:00 2001 From: Vikhyath Mondreti Date: Fri, 10 Oct 2025 12:04:59 -0700 Subject: [PATCH] fix test webhook url (#1594) --- apps/sim/app/api/webhooks/[id]/test-url/route.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/sim/app/api/webhooks/[id]/test-url/route.ts b/apps/sim/app/api/webhooks/[id]/test-url/route.ts index c6bea0675..b4da4142d 100644 --- a/apps/sim/app/api/webhooks/[id]/test-url/route.ts +++ b/apps/sim/app/api/webhooks/[id]/test-url/route.ts @@ -64,13 +64,13 @@ export async function POST(request: NextRequest, { params }: { params: Promise<{ return NextResponse.json({ error: 'Forbidden' }, { status: 403 }) } - const origin = new URL(request.url).origin - const effectiveOrigin = origin.includes('localhost') - ? env.NEXT_PUBLIC_APP_URL || origin - : origin + if (!env.NEXT_PUBLIC_APP_URL) { + logger.error(`[${requestId}] NEXT_PUBLIC_APP_URL not configured`) + return NextResponse.json({ error: 'Server configuration error' }, { status: 500 }) + } const token = await signTestWebhookToken(id, ttlSeconds) - const url = `${effectiveOrigin}/api/webhooks/test/${id}?token=${encodeURIComponent(token)}` + const url = `${env.NEXT_PUBLIC_APP_URL}/api/webhooks/test/${id}?token=${encodeURIComponent(token)}` logger.info(`[${requestId}] Minted test URL for webhook ${id}`) return NextResponse.json({