Skip to content

Commit 8e95c5e

Browse files
authored
Merge pull request router-for-me#134 from router-for-me/hg
feat(managementasset): add MANAGEMENT_STATIC_PATH override
2 parents f58d0fa + 93f0e65 commit 8e95c5e

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ A web-based management center for CLIProxyAPI.
8282

8383
Set `remote-management.disable-control-panel` to `true` if you prefer to host the management UI elsewhere; the server will skip downloading `management.html` and `/management.html` will return 404.
8484

85+
You can set the `MANAGEMENT_STATIC_PATH` environment variable to choose the directory where `management.html` is stored.
86+
8587
### Authentication
8688

8789
You can authenticate for Gemini, OpenAI, Claude, Qwen, and/or iFlow. All can coexist in the same `auth-dir` and will be load balanced.

README_CN.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ CLIProxyAPI 的基于 Web 的管理中心。
9696

9797
如果希望自行托管管理页面,可在配置中将 `remote-management.disable-control-panel` 设为 `true`,服务器将停止下载 `management.html`,并让 `/management.html` 返回 404。
9898

99+
可以通过设置环境变量 `MANAGEMENT_STATIC_PATH` 来指定 `management.html` 的存储目录。
100+
99101
### 身份验证
100102

101103
您可以分别为 Gemini、OpenAI、Claude、Qwen 和 iFlow 进行身份验证,它们可同时存在于同一个 `auth-dir` 中并参与负载均衡。

internal/managementasset/updater.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,14 @@ type releaseResponse struct {
5656

5757
// StaticDir resolves the directory that stores the management control panel asset.
5858
func StaticDir(configFilePath string) string {
59+
if override := strings.TrimSpace(os.Getenv("MANAGEMENT_STATIC_PATH")); override != "" {
60+
cleaned := filepath.Clean(override)
61+
if strings.EqualFold(filepath.Base(cleaned), managementAssetName) {
62+
return filepath.Dir(cleaned)
63+
}
64+
return cleaned
65+
}
66+
5967
configFilePath = strings.TrimSpace(configFilePath)
6068
if configFilePath == "" {
6169
return ""
@@ -74,6 +82,14 @@ func StaticDir(configFilePath string) string {
7482

7583
// FilePath resolves the absolute path to the management control panel asset.
7684
func FilePath(configFilePath string) string {
85+
if override := strings.TrimSpace(os.Getenv("MANAGEMENT_STATIC_PATH")); override != "" {
86+
cleaned := filepath.Clean(override)
87+
if strings.EqualFold(filepath.Base(cleaned), managementAssetName) {
88+
return cleaned
89+
}
90+
return filepath.Join(cleaned, ManagementFileName)
91+
}
92+
7793
dir := StaticDir(configFilePath)
7894
if dir == "" {
7995
return ""

0 commit comments

Comments
 (0)