fix(base-url): use getBaseUrl helper in copilot revert state endpoint#1706
Merged
icecrasher321 merged 2 commits intostagingfrom Oct 22, 2025
Merged
fix(base-url): use getBaseUrl helper in copilot revert state endpoint#1706icecrasher321 merged 2 commits intostagingfrom
icecrasher321 merged 2 commits intostagingfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
There was a problem hiding this comment.
Greptile Overview
Summary
This PR replaces request.nextUrl.origin with the getBaseUrl() helper function when making an internal API call to the workflow state endpoint. This change aligns with the codebase's established pattern of using getBaseUrl() for all internal API calls.
Key changes:
- Import added for
getBaseUrlfrom@/lib/urls/utils - Internal fetch call updated to use
getBaseUrl()instead ofrequest.nextUrl.origin
This is part of a broader effort in the codebase to standardize on using getBaseUrl() for internal API calls, which ensures proper URL construction based on the NEXT_PUBLIC_APP_URL environment variable. This is especially important for webhooks, callbacks, and internal service-to-service communication.
Confidence Score: 5/5
- This PR is safe to merge with no risk
- This is a simple, low-risk refactoring change that replaces a direct URL construction with a standardized helper function. The change is consistent with recent codebase-wide efforts (#1643, #1701) to use
getBaseUrl()everywhere. The helper function provides better environment-aware URL construction and the same Cookie header is still properly passed through, maintaining authentication context. - No files require special attention
Important Files Changed
File Analysis
| Filename | Score | Overview |
|---|---|---|
| apps/sim/app/api/copilot/checkpoints/revert/route.ts | 5/5 | Replaced request.nextUrl.origin with getBaseUrl() helper for consistency with codebase standards |
Sequence Diagram
sequenceDiagram
participant Client
participant RevertAPI as Checkpoint Revert API
participant StateAPI as Workflow State API
participant DB as Database
Client->>RevertAPI: POST /api/copilot/checkpoints/revert
RevertAPI->>RevertAPI: Authenticate user
RevertAPI->>DB: Fetch checkpoint by ID & userId
DB-->>RevertAPI: Return checkpoint
RevertAPI->>DB: Fetch workflow by workflowId
DB-->>RevertAPI: Return workflow
RevertAPI->>RevertAPI: Verify ownership
RevertAPI->>RevertAPI: Clean checkpoint state
Note over RevertAPI: Changed: getBaseUrl() instead of<br/>request.nextUrl.origin
RevertAPI->>StateAPI: PUT {getBaseUrl()}/api/workflows/{id}/state<br/>(with Cookie header)
StateAPI->>StateAPI: Authenticate via session
StateAPI->>StateAPI: Validate permissions
StateAPI->>DB: Save workflow state
DB-->>StateAPI: Success
StateAPI-->>RevertAPI: 200 OK
RevertAPI->>DB: Delete checkpoint
DB-->>RevertAPI: Success
RevertAPI-->>Client: 200 OK with revert details
1 file reviewed, no comments
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
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
Use getBaseUrl helper in revert state endpoint
Testing
Manually
Checklist