Please follow the below steps :
change host name here Rename Qlik Sense Server
and not foget certificate
Please mark the appropriate replies as CORRECT / HELPFUL so our team and other members know that your question(s) has been answered to your satisfaction.
So we figured out a simple solution to this.
We created the same connection name across all environments and update it with the respective connection strings and credentials. Did the same with the Folder connections too.
Once that is being done, we do not have to update the connection names in the code and the connection also needs to be set up only once across the environments.