Skip to content

feat: 支持通过http query参数 baseUrl 来动态设置 baseUrl 以支持多个域名/项目的共享使用 #506

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions server/src/main/java/cn/keking/web/filter/BaseUrlFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,14 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha
final String urlInHeader = servletRequest.getHeader("X-Base-Url");
if (StringUtils.isNotEmpty(urlInHeader)) {
baseUrl = urlInHeader;
} else if (servletRequest.getParameterMap().containsKey("baseUrl")) {
//2、支持通过http query参数 baseUrl 来动态设置 baseUrl 以支持多个域名/项目的共享使用
baseUrl = servletRequest.getParameter("baseUrl");
} else if (configBaseUrl != null && !ConfigConstants.DEFAULT_BASE_URL.equalsIgnoreCase(configBaseUrl)) {
//2、如果配置文件中配置了 baseUrl 且不为 default 则以配置文件为准
//3、如果配置文件中配置了 baseUrl 且不为 default 则以配置文件为准
baseUrl = configBaseUrl;
} else {
//3、默认动态拼接 baseUrl
//4、默认动态拼接 baseUrl
baseUrl = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
+ servletRequest.getContextPath() + "/";
}
Expand Down