Skip to content

fix(ui): Proxy agent API calls from the UI container#60

Merged
nfebe merged 2 commits intomainfrom
fix/image-agent-proxy
Apr 18, 2026
Merged

fix(ui): Proxy agent API calls from the UI container#60
nfebe merged 2 commits intomainfrom
fix/image-agent-proxy

Conversation

@nfebe
Copy link
Copy Markdown
Contributor

@nfebe nfebe commented Apr 18, 2026

The UI image now forwards /api/ and /health requests to the FlatRun agent instead of returning 404, restoring connectivity when the image replaces the host nginx that previously performed the proxy.

The agent endpoint is configurable via the AGENT_URL environment variable and defaults to host.docker.internal:8090 so the image works against an agent running on the docker host without extra wiring.

The UI image now forwards /api/ and /health requests to the FlatRun
agent instead of returning 404, restoring connectivity when the image
replaces the host nginx that previously performed the proxy.

The agent endpoint is configurable via the AGENT_URL environment
variable and defaults to host.docker.internal:8090 so the image works
against an agent running on the docker host without extra wiring.
@sourceant
Copy link
Copy Markdown

sourceant Bot commented Apr 18, 2026

Code Review Summary

The PR introduces an Nginx proxy layer within the UI container to route API requests to a backend agent. This allows the UI container to act as a standalone entry point without needing an external load balancer for basic connectivity.

🚀 Key Improvements

  • Implemented environment variable substitution for the backend agent URL.
  • Added support for WebSocket upgrades via Upgrade and Connection headers.
  • Standardized Docker image configuration by using the /etc/nginx/templates directory.

💡 Minor Suggestions

  • Re-add the /assets/ caching block to optimize performance.
  • Use a trailing slash on the /api/ location match.

Copy link
Copy Markdown

@sourceant sourceant Bot left a comment

Choose a reason for hiding this comment

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

Review complete. See the overview comment for a summary.

Comment thread nginx.conf Outdated
proxy_set_header X-Forwarded-Proto $scheme;
proxy_connect_timeout 60s;
proxy_send_timeout 60s;
proxy_read_timeout 300s;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

A 300s (5 minute) read timeout is quite high for general API calls. While useful for long-polling or heavy reports, consider if this is appropriate for all /api/ endpoints or if it should be tuned down to 60s to prevent hanging connections.

Suggested change
proxy_read_timeout 300s;
proxy_read_timeout 60s;

Collapses the separate API location blocks and the /health rewrite
into a single /api block that already covers websocket upgrades and
long-lived streams, mirroring the config the installer generates
when the UI is deployed from a dist folder.

The /assets block is also dropped since the SPA's content-hashed
filenames do not need a dedicated caching tier to behave correctly.
@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying flatrun-ui with  Cloudflare Pages  Cloudflare Pages

Latest commit: 1cd982b
Status:⚡️  Build in progress...

View logs

Copy link
Copy Markdown

@sourceant sourceant Bot left a comment

Choose a reason for hiding this comment

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

Review complete. No specific code suggestions were generated. See the overview comment for a summary.

@nfebe nfebe merged commit 091d66c into main Apr 18, 2026
3 of 4 checks passed
@nfebe nfebe deleted the fix/image-agent-proxy branch April 18, 2026 01:20
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