Closed ojith97 closed 7 years ago
Can you provide your configuration as well? When you tried zuul.ignored-services
, what did that look like?
zuul.ignored-services="*"
Just so I understand, /logout
is not a service right? If so than I can see why zuul.ignored-services
didnt work. And you are saying the filter you published above is not redirecting the request either?
while i was searching for a solution i found the below link
https://stackoverflow.com/questions/37243381/netflix-zuul-block-request-routing
according to the above link i have manage to route the request back to the client without routing to the back-end service. but the problem now i'm having is how to set the location header in the response. below is my current code
public Object run() {
RequestContext context = RequestContext.getCurrentContext();
HttpSession excistingSession = context.getRequest().getSession(false);
if(excistingSession != null){
excistingSession.invalidate();
context.unset();
context.setResponseStatusCode(302);
//context.addZuulResponseHeader("Location", "/abc/logout.to"); //Notworking
}
return null;
}
but the context.addZuulResponseHeader
is not sending the header to the client
Tried the below HTTPResponse as well
HttpServletResponse response = context.getResponse();
response.setStatus(302)
response.setHeader("Location", "/abc/logout.to");
context.unset();
context.setResponse(response);
and that didn't work either
Maybe you could take a look at this filter as an example https://github.com/spring-cloud/spring-cloud-netflix/blob/master/spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/zuul/filters/post/LocationRewriteFilter.java#L83
im not sure how this will solve my problem, because this is a post filter which will call after the request is routed to the back-end (as for my understanding). and also i want to send the location header in the response that comes in the request not by redirecting it.
finally i have manage to resolve this issue by my self below is my code
@Override
public Object run() {
RequestContext context = RequestContext.getCurrentContext();
HttpSession excistingSession = context.getRequest().getSession(false);
if(excistingSession != null){
excistingSession.invalidate();
context.setSendZuulResponse(false);
context.addZuulResponseHeader("Location", "/abc/def/logout.do");
context.setResponseStatusCode(HttpServletResponse.SC_MOVED_TEMPORARILY);
}
return null;
}
i have a use case where if "/logout" request came to the filter i do not want to redirect it to the back-end service is there anyway to archive this below is my filler class
so far i have tried "zuul.ignored-services" and "zuul.ignored-patterns" but both of them didn't work. what happens is that back-end service get called and it return 404. glad to hear any suggestions.