From 90a9fff1f01c46111d965eae378f54c39128d2e8 Mon Sep 17 00:00:00 2001 From: fanfpy Date: Sun, 6 Jul 2025 12:16:51 +0800 Subject: [PATCH] =?UTF-8?q?fix(consul):=20=E6=B7=BB=E5=8A=A0traefik?= =?UTF-8?q?=E4=B8=AD=E9=97=B4=E4=BB=B6=E4=BB=A5=E9=87=8D=E5=86=99data-serv?= =?UTF-8?q?ice=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加路径重写中间件规则,将/api/data/路径重定向到/api/public/,以解决API路径不一致问题 --- consul/config/data-service.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/consul/config/data-service.json b/consul/config/data-service.json index 5647c89..29fd51b 100644 --- a/consul/config/data-service.json +++ b/consul/config/data-service.json @@ -10,7 +10,10 @@ "tags": [ "traefik.enable=true", "traefik.http.routers.data-service.rule=PathPrefix(\"/api/data\")", - "traefik.http.routers.data-service.entrypoints=web" + "traefik.http.routers.data-service.entrypoints=web", + "traefik.http.middlewares.data-service-rewrite.replacepathregex.regex=^/api/data/(.*)", + "traefik.http.middlewares.data-service-rewrite.replacepathregex.replacement=/api/public/$1", + "traefik.http.routers.data-service.middlewares=data-service-rewrite" ], "name": "data-service", "port": 8000