fix: 使用getServletPath解决context-path导致可选认证正则匹配失败
This commit is contained in:
@@ -28,8 +28,9 @@ public class JwtAuthInterceptor implements HandlerInterceptor {
|
||||
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||
String requestURI = request.getRequestURI();
|
||||
boolean isOptionalAuthPath = OPTIONAL_AUTH_PATTERN.matcher(requestURI).matches();
|
||||
// 使用 servletPath(不含context-path),与拦截器路径匹配一致
|
||||
String servletPath = request.getServletPath();
|
||||
boolean isOptionalAuthPath = OPTIONAL_AUTH_PATTERN.matcher(servletPath).matches();
|
||||
|
||||
// 从请求头获取token
|
||||
String authHeader = request.getHeader("Authorization");
|
||||
|
||||
Reference in New Issue
Block a user