edit: patch XHR Request dengan coverage lebih luas dari monkeyPatchXML

This commit is contained in:
mario
2025-05-09 16:40:02 +07:00
parent 86ad0b38dd
commit eaa18b8389
4 changed files with 38 additions and 8 deletions

View File

@@ -102,8 +102,20 @@ export const studyDataForOverlayItem = (studyInstanceUID: string) => {
try {
const qidoRootUrl = getQidoRootUrl();
// Get the authentication token from session storage
const authToken = window.sessionStorage.getItem('ohif-auth-token');
// Create request headers with Authorization if token exists
const headers: HeadersInit = {};
if (authToken) {
headers['Authorization'] = `Bearer ${authToken}`;
}
const response = await fetch(
`${qidoRootUrl}/studies?limit=101&offset=0&fuzzymatching=false&includefield=00080050,00081030,00101010,0010004&StudyInstanceUID=${studyInstanceUID}`
`${qidoRootUrl}/studies?limit=101&offset=0&fuzzymatching=false&includefield=00080050,00081030,00101010,0010004&StudyInstanceUID=${studyInstanceUID}`,
{
headers,
}
);
if (!response.ok) {

View File

@@ -39,6 +39,15 @@ export default function initWADOImageLoader(
Accept: acceptHeader,
};
// // Patch Mario:
const authToken = sessionStorage.getItem('ohif-auth-token');
if (!authToken) {
window.location.href = '/login';
return;
}
xhrRequestHeaders.Authorization = `Bearer ${authToken}`;
if (headers) {
Object.assign(xhrRequestHeaders, headers);
}

View File

@@ -85,6 +85,14 @@ function createDicomWebApi(dicomWebConfig, servicesManager) {
if (authHeaders && authHeaders.Authorization) {
xhrRequestHeaders.Authorization = authHeaders.Authorization;
}
const authToken = sessionStorage.getItem('ohif-auth-token');
if (!authToken) {
window.location.href = '/login';
return;
}
xhrRequestHeaders.Authorization = `Bearer ${authToken}`;
return xhrRequestHeaders;
};