Skip to content

Commit

Permalink
chore: type a couple easy to type files (apache#11838)
Browse files Browse the repository at this point in the history
  • Loading branch information
Erik Ritter authored Nov 30, 2020
1 parent 19e5ce0 commit 4666445
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})
Expand Down

0 comments on commit 4666445

Please sign in to comment.