Redirect handling and actual last changes

Whoops, made last changes in the JS file instead of TS. Also added
functionality to support server redirects by using final url header.