Dotnet: RedirectUri is ignored?

I have a dotnet reverse proxy (YARP+Auth0) and an Angular Frontend, using Angulars proxy to make calls to the deployed Apis. But when developing locally, on for example default http://localhost:4200, after logging in, Auth0 redirects not to localhost but to https://dev.mydomain.com.

The redirect uri is passed with the authenticationProperties, but seems to be ignored. Any pointers?

async Task Login(HttpContext context)
{
    if ($"{context.Request.Headers.Referer}".StartsWith("http://localhost:4200/"))
    {
        redirectUri = "http://localhost:4200/";
    }

    var authenticationProperties = new LoginAuthenticationPropertiesBuilder()
        .WithRedirectUri(redirectUri!)
        .WithParameter("connection", "xxx")
        .Build();

    if (authenticationProperties.RedirectUri == "/" && context.Request.Query.ContainsKey("ReturnUrl"))
    {
        authenticationProperties.RedirectUri = context.Request.Query["ReturnUrl"];
    }

    await context.ChallengeAsync(Auth0Constants.AuthenticationScheme, authenticationProperties);
}

seems like this does the job:

        // .WithRedirectUri(redirectUri!)
         .WithParameter("redirect_uri", redirectUri!)