Allow environment variable to override endpoint

Also propagate exception cause.
Merge pull request #85 from maginatics/endpoint-environment-variable-1.5.x

Allow environment variable to override endpoint