77
88import storage from './storage' ;
99
10+ // Get the base URL from Vite configuration for correct asset paths
11+ const BASE_URL = import . meta. env . BASE_URL ;
12+
1013/**
1114 * Load vocabulary data from JSON file
1215 */
1316export const loadVocabulary = async ( ) => {
1417 try {
15- const response = await fetch ( '/ data/vocabulary.json' ) ;
18+ const response = await fetch ( ` ${ BASE_URL } data/vocabulary.json` ) ;
1619 if ( ! response . ok ) {
1720 throw new Error ( `Failed to load vocabulary: ${ response . statusText } ` ) ;
1821 }
@@ -29,7 +32,7 @@ export const loadVocabulary = async () => {
2932 */
3033export const loadCollocations = async ( ) => {
3134 try {
32- const response = await fetch ( '/ data/collocations_complete.json' ) ;
35+ const response = await fetch ( ` ${ BASE_URL } data/collocations_complete.json` ) ;
3336 if ( ! response . ok ) {
3437 throw new Error ( `Failed to load collocations: ${ response . statusText } ` ) ;
3538 }
@@ -48,7 +51,7 @@ export const loadHints = async () => {
4851 try {
4952 // Add cache-busting parameter to force reload of updated hints
5053 const cacheBuster = Date . now ( ) ;
51- const response = await fetch ( `/ data/collocation_hints.json?v=${ cacheBuster } ` ) ;
54+ const response = await fetch ( `${ BASE_URL } data/collocation_hints.json?v=${ cacheBuster } ` ) ;
5255 if ( ! response . ok ) {
5356 throw new Error ( `Failed to load hints: ${ response . statusText } ` ) ;
5457 }
@@ -152,7 +155,7 @@ export const loadReverseHints = async () => {
152155 try {
153156 // Add cache-busting parameter to force reload of updated hints
154157 const cacheBuster = Date . now ( ) ;
155- const response = await fetch ( `/ data/reverse_hints.json?v=${ cacheBuster } ` ) ;
158+ const response = await fetch ( `${ BASE_URL } data/reverse_hints.json?v=${ cacheBuster } ` ) ;
156159 if ( ! response . ok ) {
157160 console . warn ( 'Reverse hints not found, will use fallback' ) ;
158161 return null ;
0 commit comments