@@ -132,6 +132,14 @@ <h5 class="card-title">Result</h5>
132132< script src ="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js " integrity ="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p " crossorigin ="anonymous "> </ script >
133133< script src ="https://cdn.jsdelivr.net/gh/google/code-prettify@master/loader/run_prettify.js?lang=yaml&css&skin=sunburst "> </ script >
134134< script >
135+ // Automatically detect base path for API calls when deployed in subdomain
136+ const BASE_PATH = ( ( ) => {
137+ const path = window . location . pathname ;
138+ if ( path === '/' || path === '' ) return '' ;
139+ const match = path . match ( / ^ \/ [ ^ \/ ] + / ) ; // Match first path segment
140+ return match ? match [ 0 ] : '' ;
141+ } ) ( ) ;
142+
135143// Namespace abbreviation dictionary
136144const NAMESPACE_PREFIXES = {
137145 'http://www.w3.org/ns/csvw#' : 'csvw' ,
@@ -321,8 +329,8 @@ <h5 class="card-title">Result</h5>
321329 try {
322330 // Fetch types from both documents
323331 const [ dataResponse , templateResponse ] = await Promise . all ( [
324- fetch ( `/api/types?url=${ encodeURIComponent ( dataUrl ) } ` ) ,
325- fetch ( `/api/types?url=${ encodeURIComponent ( templateUrl ) } ` )
332+ fetch ( `${ BASE_PATH } /api/types?url=${ encodeURIComponent ( dataUrl ) } ` ) ,
333+ fetch ( `${ BASE_PATH } /api/types?url=${ encodeURIComponent ( templateUrl ) } ` )
326334 ] ) ;
327335
328336 if ( ! dataResponse . ok || ! templateResponse . ok ) {
@@ -446,8 +454,8 @@ <h5 class="card-title">Result</h5>
446454 try {
447455 // Fetch entities from both documents
448456 const [ dataResponse , templateResponse ] = await Promise . all ( [
449- fetch ( `/api/entities?url=${ encodeURIComponent ( dataUrl ) } &types=${ encodeURIComponent ( dataTypes . join ( ',' ) ) } ` ) ,
450- fetch ( `/api/entities?url=${ encodeURIComponent ( templateUrl ) } &types=${ encodeURIComponent ( templateTypes . join ( ',' ) ) } ` )
457+ fetch ( `${ BASE_PATH } /api/entities?url=${ encodeURIComponent ( dataUrl ) } &types=${ encodeURIComponent ( dataTypes . join ( ',' ) ) } ` ) ,
458+ fetch ( `${ BASE_PATH } /api/entities?url=${ encodeURIComponent ( templateUrl ) } &types=${ encodeURIComponent ( templateTypes . join ( ',' ) ) } ` )
451459 ] ) ;
452460
453461 if ( ! dataResponse . ok || ! templateResponse . ok ) {
@@ -597,7 +605,7 @@ <h6 class="card-subtitle mb-2 text-muted">Map Information Line and Column Entiti
597605 btn . innerHTML = '<span class="spinner-border spinner-border-sm" role="status"></span> Creating...' ;
598606
599607 try {
600- const response = await fetch ( ' /api/mapping' , {
608+ const response = await fetch ( ` ${ BASE_PATH } /api/mapping` , {
601609 method : 'POST' ,
602610 headers : {
603611 'Content-Type' : 'application/json' ,
0 commit comments