@@ -7,15 +7,7 @@ import clonedeep from 'lodash/cloneDeep'
77import getUserAgent from './core/Util.js'
88import contentstackClient from './contentstackClient.js'
99import httpClient from './core/contentstackHTTPClient.js'
10- const regionHostMap = {
11- NA : 'api.contentstack.io' ,
12- EU : 'eu-api.contentstack.com' ,
13- AU : 'au-api.contentstack.com' ,
14- AZURE_NA : 'azure-na-api.contentstack.com' ,
15- AZURE_EU : 'azure-eu-api.contentstack.com' ,
16- GCP_NA : 'gcp-na-api.contentstack.com' ,
17- GCP_EU : 'gcp-eu-api.contentstack.com'
18- }
10+ import { getContentstackEndpoint } from '@contentstack/utils'
1911
2012/**
2113 * Create client instance
@@ -179,18 +171,12 @@ const regionHostMap = {
179171 * @returns {ContentstackClient } Instance of ContentstackClient
180172 */
181173export function client ( params = { } ) {
182- let defaultHostName
174+ let defaultHostName = params . region
175+ ? getContentstackEndpoint ( params . region . toUpperCase ( ) , 'management' , true )
176+ : getContentstackEndpoint ( 'NA' , 'contentManagement' , true )
183177
184- if ( params . region ) {
185- const region = params . region . toUpperCase ( )
186- if ( ! regionHostMap [ region ] ) {
187- throw new Error ( `Invalid region '${ params . region } ' provided. Allowed regions are: ${ Object . keys ( regionHostMap ) . join ( ', ' ) } ` )
188- }
189- defaultHostName = regionHostMap [ region ]
190- } else if ( params . host ) {
178+ if ( params . host ) {
191179 defaultHostName = params . host
192- } else {
193- defaultHostName = regionHostMap [ 'NA' ]
194180 }
195181
196182 const defaultParameter = {
0 commit comments