mirror of https://github.com/apache/superset.git
chore: type a couple easy to type files (#11838)
This commit is contained in:
parent
19e5ce0ac7
commit
46664452a7
|
@ -20,14 +20,16 @@ import { SupersetClient, logging } from '@superset-ui/core';
|
||||||
import parseCookie from 'src/utils/parseCookie';
|
import parseCookie from 'src/utils/parseCookie';
|
||||||
|
|
||||||
export default function setupClient() {
|
export default function setupClient() {
|
||||||
const csrfNode = document.querySelector('#csrf_token');
|
const csrfNode = document.querySelector<HTMLInputElement>('#csrf_token');
|
||||||
const csrfToken = csrfNode ? csrfNode.value : null;
|
const csrfToken = csrfNode?.value;
|
||||||
|
|
||||||
// when using flask-jwt-extended csrf is set in cookies
|
// when using flask-jwt-extended csrf is set in cookies
|
||||||
const cookieCSRFToken = parseCookie().csrf_access_token || '';
|
const cookieCSRFToken = parseCookie().csrf_access_token || '';
|
||||||
|
|
||||||
SupersetClient.configure({
|
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) || '',
|
host: (window.location && window.location.host) || '',
|
||||||
csrfToken: csrfToken || cookieCSRFToken,
|
csrfToken: csrfToken || cookieCSRFToken,
|
||||||
})
|
})
|
Loading…
Reference in New Issue