Skip to content

Commit 0f91563

Browse files
Region support added
1 parent 6c560f3 commit 0f91563

File tree

1 file changed

+10
-6
lines changed
  • packages/contentstack-bootstrap/src/bootstrap

1 file changed

+10
-6
lines changed

packages/contentstack-bootstrap/src/bootstrap/utils.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -197,14 +197,17 @@ const envFileHandler = async (
197197
customHost = region?.cma?.substring(8);
198198
}
199199

200-
const getGraphqlHost = (name?: string): string => {
201-
const normalizedRegion = name?.toLowerCase();
202-
if (!normalizedRegion || normalizedRegion === 'na' || normalizedRegion === 'aws-na') {
203-
return 'graphql.contentstack.com';
200+
const getGraphqlHost = (): string => {
201+
if (!isPredefinedRegion) {
202+
return cdnHost.replace('-cdn.', '-graphql.');
204203
}
205-
return `${normalizedRegion}-graphql.contentstack.com`;
204+
const normalizedRegion = regionName?.toLowerCase();
205+
if (!normalizedRegion || normalizedRegion === 'na' || normalizedRegion === 'aws-na' || normalizedRegion === 'us') {
206+
return cdnHost.replace('cdn.', 'graphql.').replace('.io', '.com');
207+
}
208+
return cdnHost.replace('-cdn.', '-graphql.');
206209
};
207-
const graphqlHost = getGraphqlHost(regionName);
210+
const graphqlHost = getGraphqlHost();
208211

209212
let imageHostname: string;
210213
if (isPredefinedRegion && region?.cda) {
@@ -214,6 +217,7 @@ const envFileHandler = async (
214217
const baseHost = region.cda.replace(/^https?:\/\//, '').replace(/^[^.]+\./, '');
215218
imageHostname = `*-images.${baseHost}`;
216219
} else {
220+
//default
217221
imageHostname = '*-images.contentstack.com';
218222
}
219223
const production = environmentVariables.environment === 'production' ? true : false;

0 commit comments

Comments
 (0)