Merge pull request #8015 from dataease/pr@dev-v2@feat_context_path

feat: 增加访问前缀配置 close #7999
This commit is contained in:
fit2cloud-chenyw 2024-02-06 11:43:40 +08:00 committed by GitHub
commit bf7353882d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 17 additions and 2 deletions

View File

@ -1,3 +1,3 @@
# 接口前缀
VITE_API_BASEPATH="/de2api"
VITE_API_BASEPATH="./de2api"
VITE_VERSION="0.0.0"

View File

@ -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) {

View File

@ -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<String> 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, "");
}