From f87333eda94977048520dd2d4a2e68b0c61c9244 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Mon, 27 Jan 2025 16:46:11 -0500 Subject: [PATCH] feat(DICOMWeb): add global headers to requests --- src/core/dicom-web-api.ts | 3 +++ src/utils/fetch.ts | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/core/dicom-web-api.ts b/src/core/dicom-web-api.ts index 0f24f709c..cd24fe353 100644 --- a/src/core/dicom-web-api.ts +++ b/src/core/dicom-web-api.ts @@ -1,5 +1,6 @@ import { cleanUndefined } from '@/src/utils'; import { api } from 'dicomweb-client-typed'; +import { globalHeaders } from '@/src/utils/fetch'; export interface FetchStudyOptions { studyInstanceUID: string; @@ -66,8 +67,10 @@ function toFile(instance: ArrayBuffer) { } function makeClient(dicomWebRoot: string) { + const headers = Object.fromEntries(globalHeaders.entries()); return new api.DICOMwebClient({ url: dicomWebRoot, + headers, }); } diff --git a/src/utils/fetch.ts b/src/utils/fetch.ts index fb82998f3..b1432ef0c 100644 --- a/src/utils/fetch.ts +++ b/src/utils/fetch.ts @@ -1,7 +1,7 @@ import { parseUrl } from '@/src/utils/url'; import { Awaitable } from '@vueuse/core'; -const globalHeaders = new Headers(); +export const globalHeaders = new Headers(); export function setGlobalHeader(name: string, value: string) { globalHeaders.set(name, value);