forked from github/dataease
Merge pull request #8015 from dataease/pr@dev-v2@feat_context_path
feat: 增加访问前缀配置 close #7999
This commit is contained in:
commit
bf7353882d
@ -1,3 +1,3 @@
|
||||
# 接口前缀
|
||||
VITE_API_BASEPATH="/de2api"
|
||||
VITE_API_BASEPATH="./de2api"
|
||||
VITE_VERSION="0.0.0"
|
||||
|
@ -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) {
|
||||
|
@ -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, "");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user