Skip to content

Commit 8e0553a

Browse files
committed
fix(chat-subs): always use next public app url env
1 parent 4cceb22 commit 8e0553a

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

apps/sim/lib/webhooks/webhook-helpers.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,14 @@ export async function createTeamsSubscription(
7171
}
7272

7373
// Build notification URL
74-
const requestOrigin = new URL(request.url).origin
75-
const effectiveOrigin = requestOrigin.includes('localhost')
76-
? env.NEXT_PUBLIC_APP_URL || requestOrigin
77-
: requestOrigin
78-
const notificationUrl = `${effectiveOrigin}/api/webhooks/trigger/${webhook.path}`
74+
// Always use NEXT_PUBLIC_APP_URL to ensure Microsoft Graph can reach the public endpoint
75+
if (!env.NEXT_PUBLIC_APP_URL) {
76+
teamsLogger.error(
77+
`[${requestId}] NEXT_PUBLIC_APP_URL not configured, cannot create Teams subscription`
78+
)
79+
return false
80+
}
81+
const notificationUrl = `${env.NEXT_PUBLIC_APP_URL}/api/webhooks/trigger/${webhook.path}`
7982

8083
// Subscribe to the specified chat
8184
const resource = `/chats/${chatId}/messages`

0 commit comments

Comments
 (0)