-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Hope redirection can be routed #190
Comments
@cqkisyouq Do you mean you want your routing to follow redirects? If so in configuration.json there is a property on the ReRoute called HttpHandlerOptions and that has a property called AllowAutoRedirect. If you set this to true Ocelot should follow redirects. |
@TomPallister No,I want to use the route to control the address for redirection |
Current redirection addresses are not controlled by routing |
Ahhh you want to return a 301 or 302 from Ocelot? |
@TomPallister Both return and non return can be available, but the address of the jump needs to be replaced on the specified route. |
headers->location: localhost:5000/a/b |
@cqkisyouq I'm sorry but I don't understand what you want Ocelot to do :( Please could you try and explain with more detail? Thank you :o |
@cqkisyouq are you looking for the configuration to be updated for a 301? |
@dbarkwell Yes, I want to configure the jump address because the present jump address is not controlled. |
@TomPallister The absolute address is not controlled for ocelot, and the relative address is normal. response state 302 return Redirect("http://localhost:6773/pay/Recive"); return RedirectToAction("Recive"); |
@cqkisyouq I think I might understand now. You have a service that is returning a redirect but the base url returned in the location header is for the service not Ocelot? This is not a feature that Ocelot supports at the moment. The easiest way for you to make this work is probably add a piece of middleware before ocelot that does a replace on your url. redirectmiddleware.cs public ReDirectMiddleware(RequestDelegate next
{
_next = next;
}
public async Task Invoke(HttpContext context)
{
await _next.Invoke(context);
var locations = context.Response.Headers.FirstOrDefault(x => x.Key.ToLower() == "location");
//do something with header
//not sure exactly what but you should be able to transform the response header here.
} startup.cs app.RedirectMiddleware();
app.UseOcelot().Wait(); If I am correct this is a feature I will add soon. |
@TomPallister Yes, you're right. That's the function I want. |
@TomPallister It's so fast to see the realization of this function. Thank you very much for your efforts. Now is a one to one replacement, hoping to be optimized to be a multi - to - many replacement "DownstreamHeaderTransform": { Hope to optimize the configuration: |
haha I will open another issue :) |
This should help with your location redirect use case but is not multi to many replacement yet! |
I want to have a routing configuration for a redirected address.
The text was updated successfully, but these errors were encountered: