]> arthur.barton.de Git - netdata.git/blobdiff - web/dashboard.js
registry: fixes netdata to respond to CORS with the requested origin, so that withCre...
[netdata.git] / web / dashboard.js
index de026a2d4c22f8ebe2ddedd56cfebf2f0d822d7b..8dd572029cf6a23a7fae18625fd8ff1f38245bea 100644 (file)
        };
 
        NETDATA.registry = {
-               host: null,
+               server: null,
                machine_guid: null,
+               hostname: null,
                urls: null,
 
                init: function() {
                                        xhrFields: { withCredentials: true }
                                })
                                .done(function(data) {
-                                       NETDATA.registry.host = data.registry;
+                                       NETDATA.registry.server = data.registry;
                                        NETDATA.registry.machine_guid = data.machine_guid;
+                                       NETDATA.registry.hostname = data.hostname;
 
                                        if(typeof callback === 'function')
                                                callback();
 
                access: function(callback) {
                        $.ajax({
-                                       url: NETDATA.registry.host + '/api/v1/registry?action=access&machine=' + NETDATA.registry.machine_guid + '&name=test&url=' + document.location,
+                                       url: NETDATA.registry.server + '/api/v1/registry?action=access&machine=' + NETDATA.registry.machine_guid + '&name=' + encodeURIComponent(NETDATA.registry.hostname) + '&url=' + encodeURIComponent(document.location),
                                        async: true,
                                        cache: false,
                                        xhrFields: { withCredentials: true }