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;

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 . 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 - on requesting through proxy_pass.