fix: check for no prefix and update help text (#1731)

This commit is contained in:
Tobias Åström
2025-05-05 11:01:53 +02:00
committed by GitHub
parent a7617b5417
commit f65c678c80
4 changed files with 19 additions and 3 deletions

View File

@@ -71,6 +71,14 @@ const ConnectionGuid = ({ showGuid }) => (
<code>{window.location.host}</code> needs to be whitelisted in QMC in your Qlik Sense on Windows deployment. In
addition, you need to enable <i>Has secure attribute</i> and set <i>SameSite attribute</i> to <i>None</i>.
<br />
Also some &quot;Additional reponse headers&quot; needs to align with the whitelisted domain:
<ul>
<li>
Access-Control-Allow-Origin: <code>{window.location.host}</code>
</li>
<li>Access-Control-Allow-Credentials: true</li>
<li>Access-Control-Expose-Headers: qlik-csrf-token</li>
</ul>
Make sure you are logged in to Qlik Sense in another browser tab.
</Typography>
<Typography variant="subtitle1" gutterBottom>

View File

@@ -168,7 +168,9 @@ const connect = async () => {
};
}
const csrfToken = await getCsrfToken(`https://${enigmaInfo.host}/${enigmaInfo.prefix}`);
const csrfToken = await getCsrfToken(
`https://${enigmaInfo.host}${enigmaInfo.prefix ? `/${enigmaInfo.prefix}` : ''}`
);
const url = SenseUtilities.buildUrl({
secure: false,
...enigmaInfo,

View File

@@ -30,7 +30,9 @@ export const useOpenApp = ({ info }) => {
const { webSocketUrl } = await (await fetch(`/auth/getSocketUrl/${info?.enigma.appId}`)).json();
url = webSocketUrl;
} else {
const csrfToken = await getCsrfToken(`https://${enigmaInfo.host}/${enigmaInfo.prefix}`);
const csrfToken = await getCsrfToken(
`https://${enigmaInfo.host}${enigmaInfo.prefix ? `/${enigmaInfo.prefix}` : ''}`
);
url = SenseUtilities.buildUrl({ ...enigmaInfo, ...{ urlParams: { 'qlik-csrf-token': csrfToken } } });
}

View File

@@ -1,7 +1,11 @@
export default async function getCsrfToken(host) {
try {
const res = await fetch(`${host}/qps/csrftoken`, { credentials: 'include' });
return res.headers.get('QLIK-CSRF-TOKEN');
const token = res.headers.get('QLIK-CSRF-TOKEN');
if (token) {
return token;
}
return '';
} catch (err) {
console.log('Failed to fetch csrf-token', err);
}