Skip to content

Commit 06b71fa

Browse files
author
w7years
committed
🚀 feat(Dockerfile): set default port to 3002 and expose it for the application
🐛 fix(reverse_proxy.go): improve error handling message in the proxy request
1 parent af6aad1 commit 06b71fa

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

Dockerfile

+3
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,13 @@ COPY --from=builder /app/config.yaml .
3030

3131
# 设置环境变量,指定默认配置文件路径
3232
ENV CONFIG_PATH=/app/config.yaml
33+
ENV PORT=3002
3334

3435
# 复制入口脚本
3536
COPY entrypoint.sh /app/entrypoint.sh
3637
RUN chmod +x /app/entrypoint.sh
3738

39+
EXPOSE $PORT
40+
3841
# 设置入口点
3942
ENTRYPOINT ["/app/entrypoint.sh"]

internal/proxy/reverse_proxy.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"ai-api-proxy/internal/config"
55
"ai-api-proxy/internal/middleware"
66
"ai-api-proxy/pkg/logger"
7+
"fmt"
78
"net"
89
"net/http"
910
"net/http/httputil"
@@ -107,7 +108,7 @@ func NewOpenAIReverseProxy(cfg *config.Config) (*httputil.ReverseProxy, error) {
107108

108109
// 处理错误
109110
ErrorHandler: func(w http.ResponseWriter, r *http.Request, err error) {
110-
middleware.ErrorHandler(w, "代理请求失败", http.StatusBadGateway)
111+
middleware.ErrorHandler(w, fmt.Sprintf("代理请求失败: %v", err), http.StatusBadGateway)
111112
},
112113
}
113114

0 commit comments

Comments
 (0)