Skip to content

fix(ai-gateway): resolve gateway by app id in the path#226

Open
yardend-wix wants to merge 3 commits into
mainfrom
fix/ai-gateway-app-id-route
Open

fix(ai-gateway): resolve gateway by app id in the path#226
yardend-wix wants to merge 3 commits into
mainfrom
fix/ai-gateway-app-id-route

Conversation

@yardend-wix

@yardend-wix yardend-wix commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

Why

base44.aiGateway.connection() built the domain-routed gateway URL:

baseURL: `${serverUrl}/api/ai/openai/v1`

That endpoint resolves the app from the request Host. But in the browser the SDK targets the shared platform host (serverUrl defaults to https://base44.app), so when a backend function calls the gateway, the injected Base44-Api-Url is that shared host — the call lands on a host that resolves to no app and 404s ("App not found for this domain").

@claude

claude Bot commented Jul 9, 2026

Copy link
Copy Markdown

Claude encountered an error —— View job


I'll analyze this and get back to you.

@claude

claude Bot commented Jul 9, 2026

Copy link
Copy Markdown

Claude encountered an error —— View job


I'll analyze this and get back to you.

yardend-wix and others added 2 commits July 9, 2026 16:02
connection() built the domain-routed gateway URL (${serverUrl}/api/ai/openai/v1),
which requires the request Host to resolve the app. In the browser the SDK
targets the shared host, so a backend function's gateway call lands on a host
that resolves to no app and 404s ("App not found for this domain").

Build the app_id-routed URL instead (${serverUrl}/api/apps/${appId}/ai/openai/v1),
matching how every other runtime module (entities, functions, connectors,
analytics, ...) places appId in the path. The gateway then resolves the app
from the URL regardless of which host the request came in on.

Pairs with the backend app_id mount in base44-dev/apper#15443.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…party SDKs

Replace the Mastra and OpenAI-SDK examples with a single minimal example
showing the connection() -> { baseURL, token } handoff against the
OpenAI-compatible Chat Completions endpoint, and drop specific library names
from the module prose. Keeps the docs client-agnostic ("any OpenAI-compatible
client") instead of pinning third-party SDKs/versions.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@yardend-wix yardend-wix force-pushed the fix/ai-gateway-app-id-route branch from 4f6024f to ee4d816 Compare July 9, 2026 13:03
@claude

claude Bot commented Jul 9, 2026

Copy link
Copy Markdown

Claude encountered an error —— View job


I'll analyze this and get back to you.

@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown

🚀 Package Preview Available!


Install this PR's preview build with npm:

npm i @base44-preview/sdk@0.8.37-pr.226.49a8ffd

Prefer not to change any import paths? Install using npm alias so your code still imports @base44/sdk:

npm i "@base44/sdk@npm:@base44-preview/sdk@0.8.37-pr.226.49a8ffd"

Or add it to your package.json dependencies:

{
  "dependencies": {
    "@base44/sdk": "npm:@base44-preview/sdk@0.8.37-pr.226.49a8ffd"
  }
}

Preview published to npm registry — try new features instantly!

…aw fetch

Replace the bare fetch example with a compact ToolLoopAgent — a background
action triggered on a record, with tools that carry input schemas and a finish
tool — matching the SDK's house example style (no Deno/npm: scaffolding).
Keeps the "point any OpenAI-compatible client at baseURL/token" note.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@claude

claude Bot commented Jul 9, 2026

Copy link
Copy Markdown

Claude encountered an error —— View job


I'll analyze this and get back to you.

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.

2 participants