Skip to content

Commit 0c24eb9

Browse files
QinYuuuuRader
authored andcommitted
fix: ensure target URL in ProxyToApi function has a valid scheme
1 parent 6634859 commit 0c24eb9

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

aigateway/handler/mcp.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66
"log/slog"
77
"net/http"
8+
"strings"
89

910
"github.com/gin-gonic/gin"
1011
"opencsg.com/csghub-server/api/httpbase"
@@ -94,6 +95,9 @@ func (m *MCPProxyHandlerImpl) ProxyToApi(api string) gin.HandlerFunc {
9495
}
9596
api := ctx.Param("any")
9697
target := mcpService.Endpoint
98+
if !strings.HasPrefix(target, "https://") && !strings.HasPrefix(target, "http://") {
99+
target = "https://" + target
100+
}
97101
rp, err := proxy.NewReverseProxy(target)
98102
if err != nil {
99103
slog.Error("fail to create mcp reverse proxy", slog.Any("err", err))

component/space.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1175,7 +1175,6 @@ func (c *spaceComponentImpl) MCPIndex(ctx context.Context, repoFilter *types.Rep
11751175
Name: space.Repository.Name,
11761176
Description: space.Repository.Description,
11771177
Path: space.Repository.Path,
1178-
Env: space.Env,
11791178
License: space.Repository.License,
11801179
Private: space.Repository.Private,
11811180
CreatedAt: space.Repository.CreatedAt,

0 commit comments

Comments
 (0)