diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/config.js b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/config.js
index 2ec2bcdee97b22b1cb42ead576b49a3ef26feb5f..6401bdbfc038c9cb4a6a61a78fb14fcabeae31a1 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/config.js
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/config.js
@@ -1,9 +1,17 @@
 var require = (function() {
 
 	var getBaseUrl = function() {
-		var path = window.location.pathname;
-		var index = path.substr(1).indexOf("/") + 1;
-		var baseUrl = path.substring(0, index) + "/resources/api/v3";
+		// To find where the V3 API has been loaded from we scan the script tags until finding this file
+		// This way is possible to load the V3 API from a separate domain
+		var scripts = document.getElementsByTagName("script");
+		var baseUrl = null;
+		for(var sIdx = 0; sIdx < scripts.length; sIdx++) {
+			var src = scripts[sIdx].src;
+			var substringEnd = -1;
+			if((substringEnd = src.indexOf("/api/v3/config.js")) > -1) {
+				baseUrl = src.substring(0, substringEnd+"/api/v3".length);
+			}
+		}
 		return baseUrl;
 	}
 
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/config.js b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/config.js
index d07541fdce859db6fdb69a21cdf7517fd5d42928..fbeb2e1c5c04af38ba375c7de7b769bc0f5071d4 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/config.js
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/config.js
@@ -9,7 +9,7 @@ var require = (function() {
 			var src = scripts[sIdx].src;
 			var substringEnd = -1;
 			if((substringEnd = src.indexOf("/api/v3/config.js")) > -1) {
-				baseUrl = src.substring(0, substringEnd+"/api/v3".length);
+				baseUrl = src.substring(0, substringEnd);
 			}
 		}
 		return baseUrl;