Improve Access-Control-Allow-* headers pass through code and fix redirection code