So i'm working on spring project. I have compiled the angular project and added to spring by coping it into web-inf/static folder and registered it in spring using ResourceHandlerRegistry. I added an interceptor to interceptor HTTP requests ,but when i deployed my application the static resources stopped working as i learned that interceptor was blocking them. So i used excludePathPatterns for unblocking the static content and it worked but the interceptor stopped intercepting HTTP requests. I'm using spring 5 and wildfly 10. What can i do?
I tried adding addPathPatterns to interceptor as i know all my request will have /api/** but it didn't worked.
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/static/**").addResourceLocations("/static/");
registry.addResourceHandler("/assets/**").addResourceLocations("/static/assets/");
}
@Bean
SessionManagementInterceptor httpApiRequestInterceptor() {
return new SessionManagementInterceptor();
}
@Override
public void addInterceptors(InterceptorRegistry registry) {
// registry.addInterceptor(httpApiRequestInterceptor()).excludePathPatterns("/static/**","/assets/**");
registry.addInterceptor(httpApiRequestInterceptor()).addPathPatterns("/api/**")
.excludePathPatterns( new String[] {"/static/**","/assets/**"});
}
I expected it to interceptor all request starting with /api/** and to exclude the static resources. It excluded the resources but didn't intercept api requests