NGINX location directive proxy_pass not reaching backend server


I am trying to route to a backend server using Nginx proxy through docker and backend services are running in docker container locally. Root location / is getting routed whereas the location with /api/ is not getting routed.

Expected http://127.0.0.1:8080/api/authservice/login to be routed to http://127.0.0.1:8085/authservice/login

      location / {
        proxy_pass http://127.0.0.1:4200;
        .....}

    location /api/ { 
        rewrite ^/api/?(.*)$ /$1 break;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        add_header X-Content-Type-Options 'nosniff';
        add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy- 
        revalidate, max-age=0';
        server_tokens off;
        proxy_pass http://127.0.0.1:8085;
        return 200 'hello end GREET NGINX3' ;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        return 200 'hello end GREET NGINX3' ;
    }