How to apply spring boot filter based on URL pattern?
There is another option if you are able to extend OncePerRequestFilter. For example: public class SomeFilter extends OncePerRequestFilter { @Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { // your filter logic …. } @Override protected boolean shouldNotFilter(HttpServletRequest request) { String path = request.getServletPath(); return !path.startsWith(“/api/secure/”); } }