In order to make sure that your request going to vault leader node, you can use these package instead of request.
This Package is extend of requestRetry package with an option to replace the dns with ip.
HOW TO USE:
1- replace request package with:
var vaultHighAvailability = require('vault-high-availability')(server_address);
var request = vaultHighAvailability.request;
2- In your request option add these lines:
var options:{
..
..
time: true,
maxAttempts: process.env.MAX_ATTEMPT_RETRY || defaultRetryTimes,
retryDelay: process.env.RETRY_DELAY || 500,
retryStrategy: vaultHighAvailability.networkOrHttpErrorTriggerResolveDNS,
addressResolver: vaultHighAvailability.replaceDnsWithIp
}
This will handle network Or Http Error & will replace the dns with the leader ip