function doConfig() {
    if (window.location.hostname != "materialscommons.org") {
        if (typeof testconfig != 'undefined') {
            mcglobals.bypasslogin = testconfig.bypasslogin;
            mcglobals.username = testconfig.username;
            mcglobals.apihost = testconfig.apihost;
            mcglobals.apikey = testconfig.apikey;
        }
    }
}


function doConfig() {
    if (window.location.hostname === "test.materialscommons.org") {
        /*
         * test.materialscommons.org doesn't conform to the naming convention so
         * explicitly check for it and set the api path appropriately.
         */
        mcglobals.apihost = "https://apitest.materialscommons.org";
    } else {
        mcglobals.apihost = window.location.protocol + "//api." + window.location.hostname;
    }
}


Change config to remove testconfig. Build url for API from the host we are connecting to.