Move this further up the middleware stack to work with Heroku