Skip to content

fix: resolve dynamic api url to support non-localhost environments - #223

Open
Benny45123 wants to merge 1 commit into
google-gemini:mainfrom
Benny45123:fix/144-dynamic-api-url
Open

Benny45123 wants to merge 1 commit into
google-gemini:mainfrom
Benny45123:fix/144-dynamic-api-url

Conversation

@Benny45123

Copy link
Copy Markdown

Fixes #144

Problem

In frontend/src/App.tsx, the production build used a hardcoded API URL:

http://localhost:8123

When deployed in Docker, on a remote server, or accessed over a local network, the browser treated localhost as the client machine. This caused API requests such as /threads to fail with net::ERR_CONNECTION_REFUSED.

Solution

  • Use window.location.origin as the default API URL in production.
  • Add optional VITE_API_URL support for deployments where the backend is hosted separately.
  • Extend ImportMetaEnv in frontend/src/vite-env.d.ts for TypeScript type safety.
  • Add VITE_API_URL build-argument support to Dockerfile.
  • Add frontend/.env.example and update the README with configuration instructions.

Verification

  • Production defaults to window.location.origin.
  • Development mode falls back to http://localhost:2024.
  • VITE_API_URL takes precedence when provided.
  • LAN and remote deployments no longer depend on the browser's localhost.

- Dynamically resolve apiUrl to window.location.origin in production
- Support custom VITE_API_URL environment variable
- Update Dockerfile with ARG/ENV for VITE_API_URL
- Update README documentation and add frontend/.env.example

Fixes google-gemini#144
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.

Front-end request error

1 participant