From a1ceafec25f8db030b57335772c40cffe26715d3 Mon Sep 17 00:00:00 2001 From: fit2cloud-chenyw Date: Tue, 6 Feb 2024 11:42:20 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E8=AE=BF=E9=97=AE?= =?UTF-8?q?=E5=89=8D=E7=BC=80=E9=85=8D=E7=BD=AE=20close=20#7999?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/core-frontend/.env.base | 2 +- core/core-frontend/src/config/axios/service.ts | 2 +- .../java/io/dataease/utils/WhitelistUtils.java | 15 +++++++++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/core/core-frontend/.env.base b/core/core-frontend/.env.base index d9c575a520..8a93b1c1c6 100644 --- a/core/core-frontend/.env.base +++ b/core/core-frontend/.env.base @@ -1,3 +1,3 @@ # 接口前缀 -VITE_API_BASEPATH="/de2api" +VITE_API_BASEPATH="./de2api" VITE_VERSION="0.0.0" diff --git a/core/core-frontend/src/config/axios/service.ts b/core/core-frontend/src/config/axios/service.ts index c932f2a188..69e4d615a3 100644 --- a/core/core-frontend/src/config/axios/service.ts +++ b/core/core-frontend/src/config/axios/service.ts @@ -102,7 +102,7 @@ service.interceptors.request.use( config.data = qs.stringify(config.data) } if (window.DataEaseBi?.baseUrl) { - config.baseURL = window.DataEaseBi.baseUrl + 'de2api/' + config.baseURL = PATH_URL } if (linkStore.getLinkToken) { diff --git a/sdk/common/src/main/java/io/dataease/utils/WhitelistUtils.java b/sdk/common/src/main/java/io/dataease/utils/WhitelistUtils.java index dca3e61809..56965391bd 100644 --- a/sdk/common/src/main/java/io/dataease/utils/WhitelistUtils.java +++ b/sdk/common/src/main/java/io/dataease/utils/WhitelistUtils.java @@ -2,11 +2,23 @@ package io.dataease.utils; import io.dataease.constant.AuthConstant; import org.apache.commons.lang3.StringUtils; +import org.springframework.core.env.Environment; import java.util.List; +import java.util.Objects; public class WhitelistUtils { + private static String contextPath; + + + public static String getContextPath() { + if (StringUtils.isBlank(contextPath)) { + contextPath = Objects.requireNonNull(CommonBeanFactory.getBean(Environment.class)).getProperty("server.servlet.context-path", String.class); + } + return contextPath; + } + public static List WHITE_PATH = List.of( "/login/localLogin", "/apisix/check", @@ -25,6 +37,9 @@ public class WhitelistUtils { "/"); public static boolean match(String requestURI) { + if (StringUtils.startsWith(requestURI, getContextPath())) { + requestURI = requestURI.replaceFirst(getContextPath(), ""); + } if (StringUtils.startsWith(requestURI, AuthConstant.DE_API_PREFIX)) { requestURI = requestURI.replaceFirst(AuthConstant.DE_API_PREFIX, ""); }