Skip to content

feat(frontend): add catch-all proxy route for ambient API v1#1511

Draft
jsell-rh wants to merge 5 commits intomainfrom
jsell/feat/frontend-api-proxy
Draft

feat(frontend): add catch-all proxy route for ambient API v1#1511
jsell-rh wants to merge 5 commits intomainfrom
jsell/feat/frontend-api-proxy

Conversation

@jsell-rh
Copy link
Copy Markdown
Contributor

@jsell-rh jsell-rh commented May 5, 2026

Summary

  • Add /api/ambient/v1/[...path] catch-all Next.js API route that proxies all HTTP methods (GET, POST, PUT, PATCH, DELETE) to the ambient-api-server backend
  • Add API_SERVER_URL env var configuration to config.ts, env.ts, and .env.example (default: http://localhost:8000)
  • Support SSE/streaming responses (text/event-stream, application/x-ndjson) via TransformStream pipe-through pattern matching existing AG-UI events proxy
  • Forward auth headers via buildForwardHeadersAsync for consistent authentication

Test plan

  • tsc --noEmit passes with 0 errors
  • npm run build passes with 0 errors, 0 warnings
  • Manual test: verify proxy forwards requests to ambient-api-server in a local dev environment
  • Manual test: verify SSE streaming works through the proxy
  • Manual test: verify 502 error handling when ambient-api-server is unavailable

Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com

Add /api/ambient/v1/[...path] catch-all route that proxies requests to
the ambient-api-server backend. Supports all HTTP methods, SSE streaming,
and request body forwarding with auth header injection.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@netlify
Copy link
Copy Markdown

netlify Bot commented May 5, 2026

Deploy Preview for cheerful-kitten-f556a0 canceled.

Name Link
🔨 Latest commit c9b912f
🔍 Latest deploy log https://app.netlify.com/projects/cheerful-kitten-f556a0/deploys/69fa4bc1beefb900082b1f87

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 5, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: f7226ed6-4599-41fb-bac7-bda18b7e06de

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch jsell/feat/frontend-api-proxy
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch jsell/feat/frontend-api-proxy

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

jsell-rh and others added 4 commits May 5, 2026 16:03
…ng for API proxy

- Add API_SERVER_URL to base frontend deployment manifest
- Add API_SERVER_URL to e2e overlay frontend patch
- Log upstream errors for debugging
- Exclude AbortError and ResponseAborted from streaming error logs

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ev config

- Forward client Accept header for SSE endpoint compatibility
- Reject path traversal segments (.. and .)
- Add API_SERVER_URL to local-dev deployment overlays
- Remove internal hostname leak from 502 error responses

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…cases

Use Request/Response.json instead of NextRequest/NextResponse, read body
eagerly with request.text() matching all other routes, conditionally set
body only for POST/PUT/PATCH, close SSE writable when upstream body is
null to prevent client hang, and include details field in error responses.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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