[PR #5941] desktop: normalize local backend URL and add /api dev proxy #11662

Closed
opened 2026-02-16 18:16:34 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/5941

State: closed
Merged: No


Fixes #5928

Summary

I've fixed the issue where the desktop app couldn't properly connect to the API server when running with a custom port. Here's what I changed:

Changes Made:

  1. packages/desktop/src/app.tsx - Fixed the URL detection logic to use 127.0.0.1:${port} for localhost instead of trying to use the Vite dev server port
  2. packages/desktop/vite.config.ts - Added optional proxy configuration for better development experience

How I tested:

Default Port (4096):

  • Terminal 1
cd packages/opencode && bun src/index.ts
  • Terminal 2
cd packages/desktop && bun run dev

Custom Port (e.g., 8080):

  • Terminal 1
cd packages/opencode && bun src/index.ts --port=8080
  • Terminal 2
cd packages/desktop && VITE_OPENCODE_SERVER_PORT=8080 bun run dev

The desktop app will now correctly connect to the API server on whatever port you specify via the VITE_OPENCODE_SERVER_PORT environment variable, which defaults to 4096.

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/5941 **State:** closed **Merged:** No --- Fixes #5928 ## Summary I've fixed the issue where the desktop app couldn't properly connect to the API server when running with a custom port. Here's what I changed: ## Changes Made: 1. packages/desktop/src/app.tsx - Fixed the URL detection logic to use 127.0.0.1:${port} for localhost instead of trying to use the Vite dev server port 2. packages/desktop/vite.config.ts - Added optional proxy configuration for better development experience ## How I tested: Default Port (4096): - Terminal 1 ```sh cd packages/opencode && bun src/index.ts ``` - Terminal 2 ```sh cd packages/desktop && bun run dev ``` - Open http://localhost:3000 Custom Port (e.g., 8080): - Terminal 1 ```sh cd packages/opencode && bun src/index.ts --port=8080 ``` - Terminal 2 ```sh cd packages/desktop && VITE_OPENCODE_SERVER_PORT=8080 bun run dev ``` - Open http://localhost:3000 The desktop app will now correctly connect to the API server on whatever port you specify via the `VITE_OPENCODE_SERVER_PORT` environment variable, which defaults to 4096.
yindo added the pull-request label 2026-02-16 18:16:34 -05:00
yindo closed this issue 2026-02-16 18:16:34 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#11662