feat(js): reset protocol and hostname depending on initial status code