-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dynamically re-route all Zuul proxied requests to single URL #1754
Comments
It should be a "pre" filter and it should run before |
The request still makes it to the original destination. New code:
Breakpoint confirming it's run before |
What happens in |
My guess is that predecorationfilter is still running later. Maybe it needs to happen after predecoration. |
Changing the filter to run after I removed Final code:
|
Strange because I had the same need and I succeeded thanks to this post but with |
This solution is not working for me, please help me: @OverRide
application.properties zuul.routes.wf.path=/wf-service/** |
The previous answers seems to indicate that the filter needs to be triggered after the PreDecoration. Have you try to change the filterOrder to:
|
i change this also now it appending complete url twise |
Worked for me too by changing the FilterOrder to 6. I was trying to prevent routing from happening.And so removed "routeHost" from the RequestContext in the Pre Filter. Thanks @spencergibb |
Hi all, trying to achieve the same thing, |
GhanshyamRawat -> is resolved now? |
I did the same but it did not work
Prefilter: actually I am hitting |
I found one way to do this. here is my zuul config: zuul:
routes:
sevice-demo-b:
path: /b/**
url: http://localhost:5010
sevice-demo-a: /a/** The filter should be the here is the code public class ChangeUriFilter extends ZuulFilter {
@Override
public String filterType() {
return FilterConstants.PRE_TYPE;
}
@Override
public int filterOrder() {
return FilterConstants.PRE_DECORATION_FILTER_ORDER - 1;
}
@Override
public boolean shouldFilter() {
RequestContext ctx = RequestContext.getCurrentContext();
HttpServletRequest request = ctx.getRequest();
final String uri = request.getRequestURI();
return uri.contains("/helloA");
}
@Override
public Object run() throws ZuulException {
RequestContext ctx = RequestContext.getCurrentContext();
final HttpServletRequest request = ctx.getRequest();
String uri = "/b/helloB"
// change uri
request.setAttribute(WebUtils.INCLUDE_REQUEST_URI_ATTRIBUTE, url);
return null;
}
} when you request 'http://host:port/a/helloA', it will forward to 😆 |
I'm trying to forward all requests to my API to a single endpoint based upon some condition.
The
Gateway
app runs on port8080
I've created the following filter:
However after making a request to
http://localhost:8080/alerts/public
my API logs show:For some reason it appends the original PATH to the redirect PATH resulting in a request to
/outage/alerts/public
which doesn't exist. I want to make a request to just/outage
.Putting a breakpoint in my filter just as the
ctx.setRouteHost()
is called shows that correct URL (http://10.50.36.43:8082/outage/
).My
application.properties
:The text was updated successfully, but these errors were encountered: