Fix middleware url changing to propagate inside the api object