Allow environment variable to override endpoint

Also propagate exception cause.