Nginx Proxy_pass is adding www in proxy_pass url

location ~ /opp/detail/ {
add_header X-debug-message "$uri";
add_header X-debug-message "$request_uri";
if ($http_user_agent ~* "teams|twitterbot|facebookexternalhit") {
rewrite detail/one  /api/detail/one break;
proxy_pass https://example.online;
  }
}

I am using this config in Nginx to rewrite URL and request on the given domain using proxy_pass. But when the request is hit, it redirects to http://www.example.online/api/detail/one . Why it is adding unnecessary www in the domain and removing HTTPS.

I have tried proxy_set_header Host $host, but not working. I am expecting this url - https://example.online/api/detail/one on requesting through proxy_pass.