chore: type a couple easy to type files (#11838)

This commit is contained in:
Erik Ritter 2020-11-29 21:52:41 -08:00 committed by GitHub
parent 19e5ce0ac7
commit 46664452a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 5 additions and 3 deletions

View File

@ -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<HTMLInputElement>('#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,
})