Skip to content
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

添加项目前缀,日志无法插入 #731

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

xiefangzhenz
Copy link

知识星球关于访问日志无法插入的问题。
当项目添加servlet.context-path的时候,过滤器进行前缀检测,无法检测到相关路径,会导致日志记录出现问题。
iShot_2025-01-03_10 43 36

@@ -20,7 +20,8 @@ public abstract class ApiRequestFilter extends OncePerRequestFilter {
@Override
protected boolean shouldNotFilter(HttpServletRequest request) {
// 只过滤 API 请求的地址
return !StrUtil.startWithAny(request.getRequestURI(), webProperties.getAdminApi().getPrefix(),
String contextPath = request.getContextPath();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

String apiUri = request.getRequestURI().substring(request.getContextPath().length());
return !StrUtil.startWithAny(apiUri, webProperties.getAdminApi().getPrefix(), webProperties.getAppApi().getPrefix());

可以考虑优化下

Copy link
Author

@xiefangzhenz xiefangzhenz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

感谢您的建议,我已根据您的反馈进行了修改。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants