Skip to content

Commit

Permalink
Merge pull request #694 from PaulHax/rel-base-path
Browse files Browse the repository at this point in the history
chore: make base path relative
  • Loading branch information
floryst authored Jan 28, 2025
2 parents 186b19d + 1832c17 commit a814b9b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/io/itk/itkConfig.js
Original file line number Diff line number Diff line change
@@ -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'),
Expand Down
1 change: 1 addition & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ function configureSentryPlugin() {
}

export default defineConfig({
base: './',
build: {
outDir: distDir,
rollupOptions: {
Expand Down

0 comments on commit a814b9b

Please sign in to comment.