@@ -3,39 +3,17 @@ const { configHandler } = require('@contentstack/cli-utilities');
3
3
4
4
/**
5
5
* Get the appropriate app URL based on the host
6
+ * Uses the configured region from configHandler to get the uiHost
6
7
* @param {string } host - The host URL
7
8
* @returns {string } The app URL
8
9
*/
9
10
function getAppUrlFromHost ( host ) {
10
11
// Get the current region from configHandler
11
12
const currentRegion = configHandler . get ( 'region' ) ;
12
-
13
- // If we have a configured region, use its uiHost
14
13
if ( currentRegion && currentRegion . uiHost ) {
15
14
return currentRegion . uiHost ;
16
15
}
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
39
17
return regions [ 'AWS-NA' ] . uiHost ;
40
18
}
41
19
0 commit comments