define(['angular'], function(angular) { 'use strict';

    var deps = ['ngRoute'];

    angular.defineModules(deps);

    var app = angular.module('app', deps);

    app.value('realm', 'UNDB');

    app.config(['$httpProvider', function($httpProvider){

        $httpProvider.useApplyAsync(true);
        $httpProvider.interceptors.push('authenticationHttpIntercepter');
        $httpProvider.interceptors.push('realmHttpIntercepter');
    }]);

    app.factory('realmHttpIntercepter', ["realm", function(realm) {

		return {
			request: function(config) {
				var trusted = /^https:\/\/api.cbd.int\//i .test(config.url) ||
							  /^\/api\//i                 .test(config.url);

                //exception if the APi call needs to be done for different realm
                if(trusted && realm && config.params && config.params.realm && config.params.realm != realm) {
                      config.headers = angular.extend(config.headers || {}, { realm : config.params.realm });
                }
                else if(trusted && realm ) {
                    config.headers = angular.extend(config.headers || {}, { realm : realm });
                }

                return config;
			}
		};
	}]);

    return app;
});

@@ -433,16 +433,340 @@
 ');%0A    
+    $httpProvider.interceptors.push('apiHttpIntercepter');%0A    %7D%5D);%0A%0A    app.factory('apiHttpIntercepter', %5Bfunction() %7B%0A%0A%09%09return %7B%0A%09%09%09request: function(config) %7B%0A%0A                if(/%5E%5C/api%5C//i.test(config.url))%0A                    config.url = %22https://api.cbd.int%22+config.url;%0A%0A                return config;%0A%09%09%09%7D%0A%09%09%7D;%0A%09
 %7D%5D);%0A%0A  

Add API interceptor to rebase api url to https://api.cbd.int/* (helpfull for debug)