Skip to content

Commit

Permalink
fix(girder): do not run synchronous XHR
Browse files Browse the repository at this point in the history
  • Loading branch information
floryst committed Nov 8, 2021
1 parent 22600fa commit 9b16e8d
Showing 1 changed file with 1 addition and 31 deletions.
32 changes: 1 addition & 31 deletions src/girder.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,42 +10,12 @@ Vue.use(Girder);
// environment variable is set at build-time
const { girderRoute } = vtkURLExtract.extractURLParameters();

let apiRoot = girderRoute || 'https://data.kitware.com/api/v1';

let apiRootChanged = false;

function checkAPIValidity(root) {
try {
const req = new XMLHttpRequest();
req.open('GET', `${root}/system/check`, false);
req.send();
if (req.status !== 200) {
return false;
}
} catch (err) {
console.log(err);
return false;
}
return true;
}
if (!checkAPIValidity(apiRoot)) {
// eslint-disable-next-line no-alert
alert(
`The server ${apiRoot} did not respond correctly.\
This could be because the url is wrong, the server is down, or because its\
CORS policy does not permit access from this website.\
Paraview Glance is defaulting to https://data.kitware.com/api/v1.\
Hint: for localhost, try: https://localhost:9000/api/v1`
);
apiRootChanged = true;
apiRoot = 'https://data.kitware.com/api/v1';
}
const apiRoot = girderRoute || 'https://data.kitware.com/api/v1';

// Create the axios-based client to be used for all API requests
const girderRest = new RestClient({
apiRoot,
});
girderRest.apiRootChanged = apiRootChanged;
girderRest.fetchUser();

// This is passed to our Vue instance; it will be available in all components
Expand Down

0 comments on commit 9b16e8d

Please sign in to comment.