added automatic evaluation of api base url according to environment