Allow environment variable to override endpoint

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

Allow environment variable to override endpoint