mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
PR fixes issues with the socket connection. - handle socket failures - previously would either leave Canvas in an infinite loading state, or load the app even when it wouldn't function - upgrade socket.io - add headers to socket connection and modify auth connection
30 lines
861 B
JavaScript
30 lines
861 B
JavaScript
/*
|
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
* or more contributor license agreements. Licensed under the Elastic License;
|
|
* you may not use this file except in compliance with the Elastic License.
|
|
*/
|
|
import boom from 'boom';
|
|
import { API_ROUTE } from '../../common/lib/constants';
|
|
|
|
export function getRequest(server, { headers }) {
|
|
const url = `${API_ROUTE}/ping`;
|
|
|
|
return server
|
|
.inject({
|
|
method: 'POST',
|
|
url,
|
|
headers,
|
|
})
|
|
.then(res => {
|
|
if (res.statusCode !== 200) {
|
|
if (process.env.NODE_ENV !== 'production') {
|
|
console.error(
|
|
new Error(`Auth request failed: [${res.statusCode}] ${res.result.message}`)
|
|
);
|
|
}
|
|
throw boom.unauthorized('Failed to authenticate socket connection');
|
|
}
|
|
|
|
return res.request;
|
|
});
|
|
}
|