diff --git a/frontend-new/public/env-config.js b/frontend-new/public/env-config.js
new file mode 100644
index 00000000..f470ad04
--- /dev/null
+++ b/frontend-new/public/env-config.js
@@ -0,0 +1,19 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+window.__ENV__ = window.__ENV__ || {};
+window.__ENV__.API_BASE_URL = "";
diff --git a/frontend-new/public/index.html b/frontend-new/public/index.html
index 2208f39b..81229f00 100644
--- a/frontend-new/public/index.html
+++ b/frontend-new/public/index.html
@@ -25,6 +25,7 @@
RocketMQ Dashboard
+
diff --git a/frontend-new/src/api/remoteApi/remoteApi.js b/frontend-new/src/api/remoteApi/remoteApi.js
index e39a9c69..2be18161 100644
--- a/frontend-new/src/api/remoteApi/remoteApi.js
+++ b/frontend-new/src/api/remoteApi/remoteApi.js
@@ -16,7 +16,7 @@
*/
const appConfig = {
- apiBaseUrl: process.env.REACT_APP_API_BASE_URL || window.location.origin
+ apiBaseUrl: (window.__ENV__ && window.__ENV__.API_BASE_URL) || process.env.REACT_APP_API_BASE_URL || window.location.origin
};
let _redirectHandler = null;
diff --git a/src/main/docker/Dockerfile b/src/main/docker/Dockerfile
index 2961fed9..485da525 100644
--- a/src/main/docker/Dockerfile
+++ b/src/main/docker/Dockerfile
@@ -20,4 +20,7 @@ VOLUME /tmp
ADD rocketmq-dashboard-*.jar rocketmq-dashboard.jar
RUN sh -c 'touch /rocketmq-dashboard.jar'
ENV JAVA_OPTS=""
-ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -jar /rocketmq-dashboard.jar" ]
+ENV API_BASE_URL=""
+COPY env-config-entrypoint.sh /env-config-entrypoint.sh
+RUN chmod +x /env-config-entrypoint.sh
+ENTRYPOINT [ "/env-config-entrypoint.sh" ]
diff --git a/src/main/docker/env-config-entrypoint.sh b/src/main/docker/env-config-entrypoint.sh
new file mode 100755
index 00000000..f6837d8b
--- /dev/null
+++ b/src/main/docker/env-config-entrypoint.sh
@@ -0,0 +1,31 @@
+#!/bin/sh
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# If API_BASE_URL is set, extract env-config.js from the jar and update it
+if [ -n "$API_BASE_URL" ]; then
+ TMP_DIR=$(mktemp -d)
+ cd "$TMP_DIR"
+ jar xf /rocketmq-dashboard.jar BOOT-INF/classes/static/env-config.js
+ cat > BOOT-INF/classes/static/env-config.js << EOF
+window.__ENV__ = window.__ENV__ || {};
+window.__ENV__.API_BASE_URL = "$API_BASE_URL";
+EOF
+ jar uf /rocketmq-dashboard.jar BOOT-INF/classes/static/env-config.js
+ cd /
+ rm -rf "$TMP_DIR"
+fi
+
+exec java $JAVA_OPTS -jar /rocketmq-dashboard.jar