changed protocol determination in url building to work on heroku behind reverse proxy