A connect middleware to ensure requests are switched between HTTP and HTTPS properly