curl's -L (--location) option follows a redirected URL:
curl -LX POST ...
But the caveat is that, this will follow redirections after login. If the login page redirects to another login page where you need to (re)submit the same POST request, then you need to use the --location-trusted option to make all the redirected URLs as trusted, otherwise curl will send the POST authentication info only to the initial URL. So if you trust the redirected URL, do:
curl -L --location-trusted -X POST ...