diff --git a/superset-frontend/src/setup/setupClient.js b/superset-frontend/src/setup/setupClient.ts similarity index 83% rename from superset-frontend/src/setup/setupClient.js rename to superset-frontend/src/setup/setupClient.ts index 0f1a039f679..11f3f6a1a28 100644 --- a/superset-frontend/src/setup/setupClient.js +++ b/superset-frontend/src/setup/setupClient.ts @@ -20,14 +20,16 @@ import { SupersetClient, logging } from '@superset-ui/core'; import parseCookie from 'src/utils/parseCookie'; export default function setupClient() { - const csrfNode = document.querySelector('#csrf_token'); - const csrfToken = csrfNode ? csrfNode.value : null; + const csrfNode = document.querySelector('#csrf_token'); + const csrfToken = csrfNode?.value; // when using flask-jwt-extended csrf is set in cookies const cookieCSRFToken = parseCookie().csrf_access_token || ''; SupersetClient.configure({ - protocol: (window.location && window.location.protocol) || '', + protocol: ['http:', 'https:'].includes(window?.location?.protocol) + ? (window?.location?.protocol as 'http:' | 'https:') + : undefined, host: (window.location && window.location.host) || '', csrfToken: csrfToken || cookieCSRFToken, }) diff --git a/superset-frontend/src/setup/setupFormatters.js b/superset-frontend/src/setup/setupFormatters.ts similarity index 100% rename from superset-frontend/src/setup/setupFormatters.js rename to superset-frontend/src/setup/setupFormatters.ts diff --git a/superset-frontend/src/setup/setupPluginsExtra.js b/superset-frontend/src/setup/setupPluginsExtra.ts similarity index 100% rename from superset-frontend/src/setup/setupPluginsExtra.js rename to superset-frontend/src/setup/setupPluginsExtra.ts diff --git a/superset-frontend/src/utils/errorMessages.js b/superset-frontend/src/utils/errorMessages.ts similarity index 100% rename from superset-frontend/src/utils/errorMessages.js rename to superset-frontend/src/utils/errorMessages.ts