Skip to content

fix(base-url): use getBaseUrl helper in copilot revert state endpoint - #1706

Merged
icecrasher321 merged 2 commits into
stagingfrom
fix/base-url-check
Oct 22, 2025
Merged

fix(base-url): use getBaseUrl helper in copilot revert state endpoint#1706
icecrasher321 merged 2 commits into
stagingfrom
fix/base-url-check

Conversation

@icecrasher321

Copy link
Copy Markdown
Collaborator

Summary

Use getBaseUrl helper in revert state endpoint

Testing

Manually

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 22, 2025

Copy link
Copy Markdown

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

1 Skipped Deployment
ProjectDeploymentPreviewCommentsUpdated (UTC)
docsSkippedSkippedOct 22, 2025 1:34am

@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

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 getBaseUrl from @/lib/urls/utils
  • Internal fetch call updated to use getBaseUrl() instead of request.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

FilenameScoreOverview
apps/sim/app/api/copilot/checkpoints/revert/route.ts5/5Replaced 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
Loading

1 file reviewed, no comments

Edit Code Review Agent Settings | Greptile

@icecrasher321
icecrasher321 merged commit ca1156a into stagingOct 22, 2025
9 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/base-url-check branch November 6, 2025 01:25
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