Skip to content

[ISSUE #401 #405] Support runtime API base URL configuration for Docker#415

Open
itxaiohanglover wants to merge 1 commit into
apache:masterfrom
itxaiohanglover:fix/runtime-api-base-url-config
Open

[ISSUE #401 #405] Support runtime API base URL configuration for Docker#415
itxaiohanglover wants to merge 1 commit into
apache:masterfrom
itxaiohanglover:fix/runtime-api-base-url-config

Conversation

@itxaiohanglover

Copy link
Copy Markdown

What is the purpose of the change

Fixes #401, fixes #405

The frontend API base URL was hardcoded at build time. When deployed via Docker, the built image always points to localhost:8082, making it impossible to use the dashboard from other hosts without rebuilding.

Brief changelog

  • Added env-config.js loaded before React app, providing window.__ENV__.API_BASE_URL
  • Updated remoteApi.js to check runtime config first, then build-time env var, then window.location.origin
  • Added Docker entrypoint script that patches env-config.js at container startup when API_BASE_URL env var is set
  • Updated Dockerfile to use the new entrypoint

How to use

# docker-compose.yml
services:
  rocketmq-dashboard:
    image: apacherocketmq/rocketmq-dashboard:latest
    environment:
      - API_BASE_URL=http://your-host:8082

When API_BASE_URL is not set, the frontend defaults to window.location.origin (same-origin), preserving backward compatibility.

…ion for Docker

The frontend API base URL was hardcoded at build time, causing issues
when deploying via Docker (the built image always points to
localhost:8082). This commit introduces a runtime configuration
mechanism:

- Add env-config.js loaded before React app, providing window.__ENV__
- Update remoteApi.js to check window.__ENV__.API_BASE_URL first
- Add Docker entrypoint script that extracts and patches env-config.js
  when API_BASE_URL environment variable is set
- Users can now set API_BASE_URL in docker-compose to configure the
  frontend at container startup without rebuilding

This fixes both apache#401 (Docker localhost issue) and apache#405 (release API
localhost:8082 issue).
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.

release version 2.1.0 api localhost:8082 局域网服务器使用docker-compose部署的,出现前端api地址解析localhost问题。

1 participant