diff --git a/x-pack/plugins/cloud/common/constants.ts b/x-pack/plugins/cloud/common/constants.ts index d99bfb2c11a66..27d755ab08214 100644 --- a/x-pack/plugins/cloud/common/constants.ts +++ b/x-pack/plugins/cloud/common/constants.ts @@ -12,4 +12,4 @@ export const ELASTIC_SUPPORT_LINK = 'https://support.elastic.co/'; */ export const CLOUD_SNAPSHOTS_PATH = 'elasticsearch/snapshots/'; -export const ELASTICSEARCH_CONFIG_ROUTE = '/api/internal/elasticsearch_config'; +export const ELASTICSEARCH_CONFIG_ROUTE = '/api/internal/cloud/elasticsearch_config'; diff --git a/x-pack/plugins/cloud/public/plugin.tsx b/x-pack/plugins/cloud/public/plugin.tsx index e7c119fe18860..e89e63dc1c15b 100644 --- a/x-pack/plugins/cloud/public/plugin.tsx +++ b/x-pack/plugins/cloud/public/plugin.tsx @@ -12,7 +12,7 @@ import type { CoreSetup, CoreStart, Plugin, PluginInitializerContext } from '@kb import { registerCloudDeploymentMetadataAnalyticsContext } from '../common/register_cloud_deployment_id_analytics_context'; import { getIsCloudEnabled } from '../common/is_cloud_enabled'; import { parseDeploymentIdFromDeploymentUrl } from '../common/parse_deployment_id_from_deployment_url'; -import { CLOUD_SNAPSHOTS_PATH } from '../common/constants'; +import { CLOUD_SNAPSHOTS_PATH, ELASTICSEARCH_CONFIG_ROUTE } from '../common/constants'; import { decodeCloudId, type DecodedCloudId } from '../common/decode_cloud_id'; import { getFullCloudUrl } from '../common/utils'; import { parseOnboardingSolution } from '../common/parse_onboarding_default_solution'; @@ -228,7 +228,9 @@ export class CloudPlugin implements Plugin { return this.elasticsearchConfig; } try { - const result = await http.get('/api/internal/elasticsearch_config'); + const result = await http.get(ELASTICSEARCH_CONFIG_ROUTE, { + version: '1', + }); this.elasticsearchConfig = { elasticsearchUrl: result.elasticsearch_url || undefined }; return this.elasticsearchConfig; diff --git a/x-pack/plugins/cloud/server/routes/elasticsearch_routes.ts b/x-pack/plugins/cloud/server/routes/elasticsearch_routes.ts index 6f35e43f2c648..5cdc2f90559cc 100644 --- a/x-pack/plugins/cloud/server/routes/elasticsearch_routes.ts +++ b/x-pack/plugins/cloud/server/routes/elasticsearch_routes.ts @@ -19,22 +19,17 @@ export function defineRoutes({ logger: Logger; router: IRouter; }) { - router.get( - { + router.versioned + .get({ path: ELASTICSEARCH_CONFIG_ROUTE, - validate: {}, - options: { - access: 'internal', - }, - }, - async (context, request, response) => { + access: 'internal', + }) + .addVersion({ version: '1', validate: {} }, async (context, request, response) => { const body: ElasticsearchConfigType = { - elasticsearch_url: elasticsearchUrl || '', + elasticsearch_url: elasticsearchUrl, }; return response.ok({ body, - headers: { 'content-type': 'application/json' }, }); - } - ); + }); }