All Http Request is hitting twice in zuul pre-filter when hitting from postman or any browser and performing all operation twice. I searched for this but could not found an answer.
I am not able to add my real implementation here so adding dummy code. My pre-filter class is:
public class ApplicationGateway extends ZuulFilter {
@Override
public String filterType() {
return "pre";
}
@Override
public int filterOrder() {
return 1;
}
@Override
public boolean shouldFilter() {
return true;
}
@Override
public Object run()
{
LOGGER.debug("PRINT");
// PRINT is printing two times in each request
}
}
and my Main class is:
@SpringBootApplication
@EnableZuulProxy
public class
Application
extends
SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(Application.class);
}
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
@Bean
public ApplicationGateway preFilter() {
return new ApplicationGateway();
}
@Bean
public PostFilter postFilter() {
return new PostFilter();
}
@Bean
public ErrorFilter errorFilter() {
return new ErrorFilter();
}
@Bean
public RouteFilter routeFilter() {
return new RouteFilter();
}
@Bean
public ApplicationGateway getAuthenticatedFilter () {
return new ApplicationGateway();
}
}
why are you returning bean of type AplicationGateway from getAuthenticatedFilter, remove that, it should work