Skip to content

Commit 59486f8

Browse files
committed
fix(router): skip static fallback for /odc_query to allow ODC proxy
The static middleware Skipper at internal/apiserver/service/router.go only skipped /cloudbeaver, /provision/v, /sqle/v and /swagger paths. Requests to /odc_query/ (with trailing slash), /odc_query/index.html and any /odc_query/<spa-path> were intercepted by the DMS HTML5 SPA fallback and got served as the DMS index.html (873B), instead of the real ODC umi index.html (~11KB). This broke the DMS UI 'SQL Workbench' entry whenever the link used the trailing-slash form (`/odc_query/?dsId=...`). Without the fix the browser landed on the DMS dashboard rather than the ODC SQL workbench, even though API and subresource proxy targets at `/odc_query/*` worked fine. Add a HasPrefix check against SqlWorkbenchController.SqlWorkbenchService.GetRootUri() (==/odc_query) at the top of the Skipper so all `/odc_query` and `/odc_query/...` requests bypass StaticConfig and reach the existing ProxyWithConfig rewrite (`/odc_query/*` -> `/$1`) targeting ODC 8989. Refs: dms-ee#865
1 parent 77260e8 commit 59486f8

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

internal/apiserver/service/router.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,13 @@ func (s *APIServer) installMiddleware() error {
451451

452452
s.echo.Use(middleware.StaticWithConfig(middleware.StaticConfig{
453453
Skipper: middleware.Skipper(func(c echo.Context) bool {
454+
// 必须先跳过 /odc_query,避免 DMS 自身的 static fallback 把
455+
// `/odc_query/`、`/odc_query/index.html` 等子路径返回为 DMS index.html,
456+
// 导致 ODC SQL 工作台跳转被截获。无尾斜杠的 /odc_query 由 Group route
457+
// 直接走 ProxyConfig 代理到 ODC 8989,本 Skipper 不影响。
458+
if strings.HasPrefix(c.Request().URL.Path, s.SqlWorkbenchController.SqlWorkbenchService.GetRootUri()) {
459+
return true
460+
}
454461
if strings.HasPrefix(c.Request().URL.Path, s.SqlWorkbenchController.CloudbeaverService.CloudbeaverUsecase.GetRootUri()) {
455462
return true
456463
}

0 commit comments

Comments
 (0)