From e3a2145546d0dd4303fcdc5e6c1aece6d8f9086a Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Mon, 27 Jan 2025 15:43:55 -0500 Subject: [PATCH] chore: make base path relative Closes #690 Co-authored-by: amazy --- src/io/itk/itkConfig.js | 14 +++++++++----- vite.config.ts | 1 + 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/io/itk/itkConfig.js b/src/io/itk/itkConfig.js index f5ce1cd15..4b6db3e92 100644 --- a/src/io/itk/itkConfig.js +++ b/src/io/itk/itkConfig.js @@ -1,9 +1,13 @@ -import { join } from '@/src/utils/path'; +const fullUrl = (relative) => { + // ex: /itk/image-io + const u = new URL(document.location); // ex: http://localhost:8043/orthanc/volview/index.html + const origin = u.origin; // ex: http://localhost:8043 + const pathParts = u.pathname.split('/'); // ex: ['', 'orthanc', 'volview', 'index.html'] + pathParts.pop(); // ex: ['', 'orthanc', 'volview'] -const base = import.meta.env.BASE_URL; - -const fullUrl = (relative) => - new URL(join(base, relative), document.location.origin).href; + const url = origin + pathParts.join('/') + relative; // ex http://localhost:8043/orthanc/volview/itk/image-io + return url; +}; const itkConfig = { pipelineWorkerUrl: fullUrl('/itk/itk-wasm-pipeline.min.worker.js'), diff --git a/vite.config.ts b/vite.config.ts index e3a4e986c..ddac39374 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -75,6 +75,7 @@ function configureSentryPlugin() { } export default defineConfig({ + base: './', build: { outDir: distDir, rollupOptions: {