Fixed problematic url creation. The baseUrl should be initialized before api.js is loaded.