Skip to content

fix(chat-subs): always use getBaseUrl helper to fetch base url - #1643

Merged
icecrasher321 merged 9 commits into
stagingfrom
fix/chat-subscription
Oct 15, 2025
Merged

fix(chat-subs): always use getBaseUrl helper to fetch base url#1643
icecrasher321 merged 9 commits into
stagingfrom
fix/chat-subscription

Conversation

@icecrasher321

@icecrasher321icecrasher321 commented Oct 15, 2025

Copy link
Copy Markdown
Collaborator

Summary

Replace all access patterns of NEXT_PUBLIC_APP_URL with getBaseUrl() to centralize logic.

Type of Change

  • Bug fix

Testing

Manually with @aadamgough

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercelBot commented Oct 15, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
ProjectDeploymentPreviewCommentsUpdated (UTC)
docsSkippedSkippedOct 15, 2025 9:06pm

@greptile-appsgreptile-appsBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Greptile Overview

Summary

Fixed Microsoft Teams webhook creation to always use NEXT_PUBLIC_APP_URL instead of request origin, ensuring Microsoft Graph API receives a valid HTTPS endpoint.

  • Removed conditional logic that attempted to use request origin with localhost fallback
  • Added explicit validation that NEXT_PUBLIC_APP_URL is configured before attempting subscription creation
  • Ensures Microsoft Graph API can reliably reach the public webhook endpoint for notifications
  • Aligns with similar pattern already used in createTelegramWebhook and createAirtableWebhookSubscription

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The change is a straightforward bug fix that simplifies the logic and makes it more robust. It removes conditional request origin logic that could fail with Microsoft Graph API and replaces it with a reliable environment variable approach. The pattern matches existing implementations for Telegram and Airtable webhooks. Since NEXT_PUBLIC_APP_URL is a required environment variable (defined with z.string().url() in env.ts:244), the validation ensures proper configuration.
  • No files require special attention

Important Files Changed

File Analysis

FilenameScoreOverview
apps/sim/lib/webhooks/webhook-helpers.ts5/5Replaced request origin logic with strict NEXT_PUBLIC_APP_URL requirement to ensure Microsoft Graph can reach public HTTPS endpoint

Sequence Diagram

sequenceDiagram
participant Client
participant WebhookAPI as Webhook API Route
participant Helper as createTeamsSubscription
participant Env as Environment Config
participant MSGraph as Microsoft Graph API
Client->>WebhookAPI: POST /api/webhooks (create Teams webhook)
WebhookAPI->>Helper: createTeamsSubscription(request, webhook, workflow)
Helper->>Env: Check NEXT_PUBLIC_APP_URL
alt NEXT_PUBLIC_APP_URL not set
Env-->>Helper: undefined
Helper->>Helper: Log error
Helper-->>WebhookAPI: return false
WebhookAPI-->>Client: 500 Error
else NEXT_PUBLIC_APP_URL configured
Env-->>Helper: https://app.sim.ai
Helper->>Helper: Build notificationUrl with NEXT_PUBLIC_APP_URL
Helper->>MSGraph: POST /subscriptions (with HTTPS notificationUrl)
MSGraph-->>Helper: Subscription created
Helper->>Helper: Update webhook with subscription ID
Helper-->>WebhookAPI: return true
WebhookAPI-->>Client: 200 Success
end
Loading

1 file reviewed, no comments

Edit Code Review Agent Settings | Greptile

@icecrasher321icecrasher321 changed the title fix(chat-subs): always use next public app url envfix(chat-subs): always use getBaseUrl helper to fetch base urlOct 15, 2025
@icecrasher321
icecrasher321 merged commit eb4821f into stagingOct 15, 2025
9 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/chat-subscription branch October 30, 2025 06:22
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@icecrasher321