Skip to content

fix: add production support for cluster-specific AI Gateway URLs#2190

Merged
alenkacz merged 1 commit into
masterfrom
av/ai-gateway-production-url-support
Jan 28, 2026
Merged

fix: add production support for cluster-specific AI Gateway URLs#2190
alenkacz merged 1 commit into
masterfrom
av/ai-gateway-production-url-support

Conversation

@alenkacz
Copy link
Copy Markdown
Contributor

Summary

Fixes AI Gateway API requests in production to use cluster-specific URLs instead of Netlify domain.

Problem

In production (Netlify), AI Gateway requests were going to:

https://main--redpanda-cloud.netlify.app/.redpanda/api/redpanda.api.aigateway.v1.GatewayService/ListGateways

Instead of the cluster-specific AI Gateway:

https://ai-gateway.{clusterId}.clusters.ign.rdpa.co/.redpanda/api/redpanda.api.aigateway.v1.GatewayService/ListGateways

Solution

Updated useAIGatewayTransport hook to:

  • Development: Use relative path /.redpanda/api with dev server proxy
  • Production: Extract cluster ID from URL and construct direct AI Gateway URL
  • Fallback: Use relative path if cluster ID cannot be extracted

Changes

  • Modified src/hooks/use-ai-gateway-transport.ts
  • Added cluster ID extraction from URL path (/clusters/{clusterId}/...)
  • Added environment-based transport configuration
  • No backend changes or environment variables needed

Testing

  • ✅ Development: Works with dev server proxy
  • ✅ Production: Constructs correct cluster-specific URLs
  • ✅ URL extraction works from /clusters/{clusterId}/console/agents/... paths

Related


🤖 Generated with Claude Code

@alenkacz alenkacz force-pushed the av/ai-gateway-production-url-support branch from 738e9af to 944a42d Compare January 28, 2026 14:51
In production embedded mode, the frontend now uses config.aiGatewayUrl
(set by cloud-ui from REACT_APP_AI_GATEWAY_URL_TEMPLATE env var) to
construct AI Gateway transport URLs.

Changes:
- Add aiGatewayUrl?: string to SetConfigArguments and Config types in config.ts
- Update useAIGatewayTransport to use config.aiGatewayUrl when isEmbedded()
- In production embedded: use config.aiGatewayUrl + /.redpanda/api
- In development: use relative /.redpanda/api with dev server proxy
- Fallback to relative path for standalone mode

Cloud-ui passes aiGatewayUrl by:
  aiGatewayUrl: process.env.REACT_APP_AI_GATEWAY_URL_TEMPLATE?.replace('{clusterId}', clusterId)

This enables environment-specific AI Gateway domains:
- Integration: https://ai-gateway.{clusterId}.clusters.ign.rdpa.co
- Staging: https://ai-gateway.{clusterId}.clusters.staging.rdpa.co
- Production: https://ai-gateway.{clusterId}.clusters.prod.rdpa.co

Fixes issue where production requests went to:
  https://main--redpanda-cloud.netlify.app/.redpanda/api/...
Instead of:
  https://ai-gateway.{clusterId}.clusters.ign.rdpa.co/.redpanda/api/...

Related: cloudv2 PR #24457 (adds REACT_APP_AI_GATEWAY_URL_TEMPLATE env var)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@alenkacz alenkacz force-pushed the av/ai-gateway-production-url-support branch from 944a42d to f1d6f4b Compare January 28, 2026 15:50
@alenkacz alenkacz merged commit e416fd4 into master Jan 28, 2026
13 checks passed
@alenkacz alenkacz deleted the av/ai-gateway-production-url-support branch January 28, 2026 16:46
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