From 41e8fc62962e169dc231c4e8d2c68f28dedd837e Mon Sep 17 00:00:00 2001 From: Sagiv Frankel Date: Thu, 23 Feb 2023 11:33:14 +0200 Subject: [PATCH] Remove cache control from meta data endpoint (#237) * Remove cache control from meta data endpoint * Run prettier * Added a comment --- packages/azure-kusto-data/src/cloudSettings.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/azure-kusto-data/src/cloudSettings.ts b/packages/azure-kusto-data/src/cloudSettings.ts index 2b5ef52..ce5c166 100644 --- a/packages/azure-kusto-data/src/cloudSettings.ts +++ b/packages/azure-kusto-data/src/cloudSettings.ts @@ -39,7 +39,19 @@ export class CloudSettings { } try { - const response = await axios.get<{ AzureAD: CloudInfo | undefined }>(kustoUri + this.METADATA_ENDPOINT); + const response = await axios.get<{ AzureAD: CloudInfo | undefined }>(kustoUri + this.METADATA_ENDPOINT, { + headers: { + "Cache-Control": "no-cache", + // Disable caching - it's being cached in memory (Service returns max-age). + // The original motivation for this is due to a CORS issue in Ibiza due to a dynamic subdomain. + // The first dynamic subdomain is attached to the cache and for some reason isn't invalidated + // when there is a new subdomain. It causes the request failure due to CORS. + // Example: + // Access to XMLHttpRequest at 'https://safrankecc.canadacentral.kusto.windows.net/v1/rest/auth/metadata' from origin + // 'https://sandbox-46-11.reactblade.portal.azure.net' has been blocked by CORS policy: The 'Access-Control-Allow-Origin' header has a value + // 'https://sandbox-46-10.reactblade.portal.azure.net' that is not equal to the supplied origin. + }, + }); if (response.status === 200) { this.cloudCache[kustoUri] = response.data.AzureAD || this.defaultCloudInfo; } else {