Possible problem with redirect logic
See original GitHub issueIf my cluster is configured to have the following members: localhost:1000, localhost:1001, localhost:1002
The following code will not redirect to the leader properly since the port that is used for the redirect is not the leader port:
internal Task Redirect(HttpContext context)
{
if (context.Request.Path.StartsWithSegments(pathMatch, StringComparison.OrdinalIgnoreCase))
{
var leader = cluster.Leader;
if (leader is null)
{
context.Response.StatusCode = StatusCodes.Status503ServiceUnavailable;
return Task.CompletedTask;
}
else if (leader.IsRemote)
{
return redirection(context.Response, new UriBuilder(context.Request.GetEncodedUrl()) { Host = leader.Endpoint.Address.ToString(), Port = applicationPortHint ?? context.Connection.LocalPort }.Uri);
}
}
return next(context);
}
should this not use something like the following?
new UriBuilder(context.Request.GetEncodedUrl()) { Host = leader.Endpoint.Address.ToString(), Port = leader.Endpoint.Port }.Uri)
Issue Analytics
- State:
- Created 3 years ago
- Comments:6
Top Results From Across the Web
Redirect logic in Page Object
Welcome! Next 10 minutes I'll show you the examples of redirection logic with Page Object pattern and what problem I'm trying to solve...
Read more >How to Fix The ERR_TOO_MANY_REDIRECTS Error
ERR_TOO_MANY_REDIRECTS is, as the error suggests, caused by too many redirects, resulting in a redirect loop. Read our post to learn more.
Read more >Advice for Logic in Javascript? - redirect
I am trying to write a redirect script for my website using Javascript and i am having some trouble with the logic. if...
Read more >redirects in React Router v6
Redirects usually happen when you want to preserve an old link and send all the traffic bound for that destination to some new...
Read more >HTTP trigger does not handle redirects on external calling ...
When I try this HTTP trigger from Logic App, it stops after the first redirect. However, when I try the same trigger from...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
From my point view, your dev and test environment should be close to the production environment to eliminate potential infrastructure problems during deployment.
I checked it on Windows, you can register additional Loopback Adapters through Control Pane as described here.