Skip to content

feat(internal): added internal api base url for internal calls#3212

Merged
waleedlatif1 merged 2 commits intostagingfrom
feat/internal
Feb 13, 2026
Merged

feat(internal): added internal api base url for internal calls#3212
waleedlatif1 merged 2 commits intostagingfrom
feat/internal

Conversation

@waleedlatif1
Copy link
Collaborator

@waleedlatif1 waleedlatif1 commented Feb 13, 2026

Summary

  • add INTERNAL_API_BASE_URL support for server-side internal /api self-calls with fallback to NEXT_PUBLIC_APP_URL
  • update tool, executor, router, MCP, A2A, template, checkpoint, guardrail, OCR, and polling internal calls to use internal base URL where appropriate
  • document and validate Helm config in values.yaml and schema while preserving backward compatibility when unset

Type of Change

  • Bug fix

Testing

Tested manually (ran bun run lint, helm lint --strict, and verified rendered env output for default and override values)

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
Copy link

vercel bot commented Feb 13, 2026

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

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview, Comment Feb 13, 2026 7:52am

Request Review

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 13, 2026

Greptile Overview

Greptile Summary

Added support for INTERNAL_API_BASE_URL environment variable to enable server-side internal API calls to use cluster-local DNS instead of public URLs, improving performance and reliability in Kubernetes environments. The implementation provides proper fallback to NEXT_PUBLIC_APP_URL when the internal URL is not configured, maintaining backward compatibility.

Key changes:

  • Created new getInternalApiBaseUrl() function with fallback logic and URL normalization
  • Updated 20 files across tools, executor, API routes, webhooks, and guardrails to use internal base URL for server-side /api self-calls
  • Added Helm configuration and schema validation with empty string default for backward compatibility
  • Intelligent routing logic in buildAPIUrl() automatically selects internal URL for /api/ routes

Architecture improvement:
This change optimizes internal service communication in containerized environments by avoiding unnecessary network hops through public load balancers when the application calls its own API endpoints.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk - well-structured implementation with proper fallback logic
  • The implementation is clean, consistent, and maintains backward compatibility. The fallback mechanism ensures existing deployments continue working without configuration changes. The changes are systematic across all relevant files, and the pattern is straightforward: replace getBaseUrl() with getInternalApiBaseUrl() for internal API calls. URL normalization is properly extracted and reused. No breaking changes introduced.
  • No files require special attention

Important Files Changed

Filename Overview
apps/sim/lib/core/utils/urls.ts Added getInternalApiBaseUrl() function with proper fallback to getBaseUrl() and extracted common URL normalization logic
apps/sim/lib/core/config/env.ts Added optional INTERNAL_API_BASE_URL environment variable definition with proper schema validation
apps/sim/executor/utils/http.ts Updated buildAPIUrl() to intelligently use internal base URL for /api/ routes
apps/sim/tools/index.ts Replaced getBaseUrl() with getInternalApiBaseUrl() for internal API calls in tool execution and MCP tool handling
helm/sim/values.yaml Added INTERNAL_API_BASE_URL configuration with empty string default and documentation
helm/sim/values.schema.json Added schema validation for INTERNAL_API_BASE_URL allowing URI format or empty string

Sequence Diagram

sequenceDiagram
    participant Client
    participant NextJS
    participant InternalAPI as Internal API Routes
    participant ExternalAPI as External Services
    
    Note over NextJS,InternalAPI: Server-Side Internal Calls
    
    NextJS->>NextJS: getInternalApiBaseUrl()
    alt INTERNAL_API_BASE_URL set
        NextJS->>NextJS: Use cluster DNS (e.g., sim-app.svc.cluster.local)
    else INTERNAL_API_BASE_URL not set
        NextJS->>NextJS: Fallback to NEXT_PUBLIC_APP_URL
    end
    
    NextJS->>InternalAPI: POST /api/workflows/{id}/execute
    InternalAPI-->>NextJS: Execution result
    
    NextJS->>InternalAPI: POST /api/webhooks/trigger/{path}
    InternalAPI-->>NextJS: Webhook processed
    
    NextJS->>InternalAPI: GET /api/tools/custom
    InternalAPI-->>NextJS: Tool definition
    
    Note over Client,NextJS: Public-Facing Calls
    Client->>NextJS: External webhook callback
    NextJS->>NextJS: getBaseUrl()
    NextJS-->>Client: Use NEXT_PUBLIC_APP_URL
Loading

Last reviewed commit: cc33742

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

20 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@waleedlatif1
Copy link
Collaborator Author

@cursor review

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

@waleedlatif1 waleedlatif1 merged commit a337aa7 into staging Feb 13, 2026
12 checks passed
@waleedlatif1 waleedlatif1 deleted the feat/internal branch February 13, 2026 07:56
Sign up for free to 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