@@ -3,39 +3,17 @@ const { configHandler } = require('@contentstack/cli-utilities');
33
44/**
55 * Get the appropriate app URL based on the host
6+ * Uses the configured region from configHandler to get the uiHost
67 * @param {string } host - The host URL
78 * @returns {string } The app URL
89 */
910function getAppUrlFromHost ( host ) {
1011 // Get the current region from configHandler
1112 const currentRegion = configHandler . get ( 'region' ) ;
12-
13- // If we have a configured region, use its uiHost
1413 if ( currentRegion && currentRegion . uiHost ) {
1514 return currentRegion . uiHost ;
1615 }
17-
18- // Handle development and staging environments (fallback for when region is not configured)
19- if ( host . includes ( 'stag' ) ) {
20- return 'https://stag-app.csnonprod.com' ;
21- }
22-
23- if ( host . includes ( 'dev' ) ) {
24- const devMatch = host . match ( / d e v ( \d + ) / ) ;
25- if ( devMatch ) {
26- const devNumber = devMatch [ 1 ] ;
27- return `https://dev${ devNumber } -app.csnonprod.com` ;
28- }
29- return 'https://dev-app.csnonprod.com' ;
30- }
31-
32- // Find matching region based on host (fallback)
33- for ( const regionConfig of Object . values ( regions ) ) {
34- if ( host . includes ( regionConfig . cma . replace ( 'https://' , '' ) ) ) {
35- return regionConfig . uiHost ;
36- }
37- }
38- // Default to NA region
16+ // Default to NA region if no region is configured
3917 return regions [ 'AWS-NA' ] . uiHost ;
4018}
4119
0 commit comments