@@ -2,37 +2,43 @@ import fetch from "node-fetch";
22import { getURL } from "../controllers/API/helpers/constants" ;
33
44export async function getBackendRootPath ( target : string ) {
5- let rootPath = '' ;
6- const configURL = getURL ( "CONFIG" )
5+ let rootPath = "" ;
6+ const configURL = getURL ( "CONFIG" ) ;
77 try {
8- console . log ( ' Fetching config from:' , `${ target } ${ configURL } ` ) ;
8+ console . log ( " Fetching config from:" , `${ target } ${ configURL } ` ) ;
99 const response = await fetch ( `${ target } ${ configURL } ` ) ;
1010 if ( ! response . ok ) {
11- console . warn ( `Failed to fetch config: ${ response . status } , using empty root path` ) ;
12- return '' ;
11+ console . warn (
12+ `Failed to fetch config: ${ response . status } , using empty root path` ,
13+ ) ;
14+ return "" ;
1315 }
1416
1517 const data = await response . json ( ) ;
16- if ( ! data || typeof data . root_path !== 'string' ) {
17- console . warn ( 'Invalid config response: root_path is missing or invalid, using empty root path' ) ;
18- return '' ;
18+ if ( ! data || typeof data . root_path !== "string" ) {
19+ console . warn (
20+ "Invalid config response: root_path is missing or invalid, using empty root path" ,
21+ ) ;
22+ return "" ;
1923 }
2024
2125 rootPath = data . root_path ;
22- console . log ( ' Using root path:' , rootPath ) ;
26+ console . log ( " Using root path:" , rootPath ) ;
2327
2428 // Set the environment variable
2529 process . env . ROOT_PATH = rootPath ;
2630
2731 // Verify it was set correctly
2832 if ( process . env . ROOT_PATH !== rootPath ) {
29- console . warn ( 'Failed to set ROOT_PATH environment variable, using empty root path' ) ;
30- return '' ;
33+ console . warn (
34+ "Failed to set ROOT_PATH environment variable, using empty root path" ,
35+ ) ;
36+ return "" ;
3137 }
3238 } catch ( error ) {
33- console . warn ( ' Failed to fetch or set backend config:' , error ) ;
34- console . warn ( ' Using empty root path' ) ;
35- return '' ;
39+ console . warn ( " Failed to fetch or set backend config:" , error ) ;
40+ console . warn ( " Using empty root path" ) ;
41+ return "" ;
3642 }
3743 return rootPath ;
3844}
0 commit comments