My code works well and gets response on my local system, but when I deploy on to the server, the error is 'The request was canceled due to the configured HttpClient.Timeout of 100 seconds elapsing'. Here is my code.
[HttpPost("GetJsoncode")]
public async Task<IActionResult> CallAPI([FromBody] JsonObject jsonBody, [FromQuery] string? validFrom, [FromQuery] string? validTo)
{
    string CertificateKey = "certKey";
    string SubscriptionKey = "123443434";
   
    string CertPath = _configuration["CertPath"]!;
    try
    {
        var handler = new HttpClientHandler();
        handler.ClientCertificates.Add(new X509Certificate2(CertPath, CertificateKey));
        handler.SslProtocols = SslProtocols.Tls | SslProtocols.Tls11 | SslProtocols.Tls12 | SslProtocols.Tls13;
        using (var client = new HttpClient(handler))
        {
            client.BaseAddress = new Uri("https://stage2.api.abc.com");
            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Accept.Add(
                new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
            client.DefaultRequestHeaders.Add("Subscription-Key", SubscriptionKey);
            var cts = new CancellationTokenSource();
            cts.CancelAfter(TimeSpan.FromSeconds(20));
            client.Timeout = TimeSpan.FromSeconds(30);
            try
            {
                      HttpResponseMessage response = await client.PostAsJsonAsync(@"api/regions/abc/code?validfrom=" + validFrom + "&validTo=" + validTo, jsonBody,cts.Token).ConfigureAwait(false);
                response.EnsureSuccessStatusCode();
                var responseContent = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
                
                return Ok(responseContent);
            }
            catch (Exception ex)
            {
                return StatusCode(400, ex.Message);
            }
        }
    }
    catch(Exception)
    {
        return StatusCode(500, "Certificate Error");
    }   
}
I have tried with long timeout, still no response. Anyone have this issue when deploying to a server with security. All other API's in the same controller are working fine on the server. And from the server I can use postman and able to get response from the target url.