I am trying to proxy public end point call https://login.microsoftonline.com/{tenant_id}/oauth2/token (POST request) to http://localhost/{tenant_id}/oauth2/token. This api call will be invoked inside an angular app. In order to avoid cors issue, I am trying to proxy the requests as same origin requests. I am using below location block in default.conf which is not working. Please advise.
location /{tenant_id} {
proxy_pass https://login.microsoftonline.com/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_cache_bypass $http_upgrade;
}
location /{tenant_id} {
proxy_pass https://login.microsoftonline.com/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_cache_bypass $http_upgrade;
}