-
Notifications
You must be signed in to change notification settings - Fork 3.3k
fix(chat-subs): always use getBaseUrl helper to fetch base url #1643
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
There was a problem hiding this comment.
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_URLis 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
createTelegramWebhookandcreateAirtableWebhookSubscription
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_URLis a required environment variable (defined withz.string().url()in env.ts:244), the validation ensures proper configuration. - No files require special attention
Important Files Changed
File Analysis
| Filename | Score | Overview |
|---|---|---|
| apps/sim/lib/webhooks/webhook-helpers.ts | 5/5 | Replaced 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
1 file reviewed, no comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Replace all access patterns of NEXT_PUBLIC_APP_URL with getBaseUrl() to centralize logic.
Type of Change
Testing
Manually with @aadamgough
Checklist