From 833879f5dc5625ea65db47f850a20ee4c13d8b96 Mon Sep 17 00:00:00 2001 From: Dawid Rutkowski Date: Tue, 28 Jun 2022 13:51:39 +0200 Subject: [PATCH 1/3] #539752 The site can't be opened in the EE and Pages in case the rendering host was connected to the site that was not published --- .../src/site/graphql-redirects-service.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/sitecore-jss/src/site/graphql-redirects-service.ts b/packages/sitecore-jss/src/site/graphql-redirects-service.ts index ef030254ae..768d1b0460 100644 --- a/packages/sitecore-jss/src/site/graphql-redirects-service.ts +++ b/packages/sitecore-jss/src/site/graphql-redirects-service.ts @@ -1,6 +1,7 @@ import { GraphQLClient, GraphQLRequestClient } from '../graphql'; import { siteNameError } from '../constants'; import debug from '../debug'; +import { RestLayoutService } from '../layout'; export const REDIRECT_TYPE_301 = 'REDIRECT_301'; export const REDIRECT_TYPE_302 = 'REDIRECT_302'; @@ -90,7 +91,15 @@ export class GraphQLRedirectsService { }); return redirectsResult - .then((result: RedirectsQueryResult) => result.site.siteInfo.redirects) + .then((result: RedirectsQueryResult) => { + const emptyResult: Array = []; + + if (result.site?.siteInfo?.redirects) { + return result.site.siteInfo.redirects; + } + + return emptyResult; + }) .catch((e) => Promise.reject(e)); } From 64f3d4ab2a823fbc2a009b2105d8f2f1d8238787 Mon Sep 17 00:00:00 2001 From: Dawid Rutkowski Date: Tue, 28 Jun 2022 13:58:34 +0200 Subject: [PATCH 2/3] Update --- packages/sitecore-jss/src/site/graphql-redirects-service.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/sitecore-jss/src/site/graphql-redirects-service.ts b/packages/sitecore-jss/src/site/graphql-redirects-service.ts index 768d1b0460..6fbdecff5f 100644 --- a/packages/sitecore-jss/src/site/graphql-redirects-service.ts +++ b/packages/sitecore-jss/src/site/graphql-redirects-service.ts @@ -1,7 +1,6 @@ import { GraphQLClient, GraphQLRequestClient } from '../graphql'; import { siteNameError } from '../constants'; import debug from '../debug'; -import { RestLayoutService } from '../layout'; export const REDIRECT_TYPE_301 = 'REDIRECT_301'; export const REDIRECT_TYPE_302 = 'REDIRECT_302'; From 0ccebf19fc095e6f71bf95be453cc34c975016a8 Mon Sep 17 00:00:00 2001 From: Dawid Rutkowski Date: Tue, 28 Jun 2022 14:55:45 +0200 Subject: [PATCH 3/3] UpdatE --- .../sitecore-jss/src/site/graphql-redirects-service.ts | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/packages/sitecore-jss/src/site/graphql-redirects-service.ts b/packages/sitecore-jss/src/site/graphql-redirects-service.ts index 6fbdecff5f..63e4d85506 100644 --- a/packages/sitecore-jss/src/site/graphql-redirects-service.ts +++ b/packages/sitecore-jss/src/site/graphql-redirects-service.ts @@ -90,15 +90,7 @@ export class GraphQLRedirectsService { }); return redirectsResult - .then((result: RedirectsQueryResult) => { - const emptyResult: Array = []; - - if (result.site?.siteInfo?.redirects) { - return result.site.siteInfo.redirects; - } - - return emptyResult; - }) + .then((result: RedirectsQueryResult) => result?.site?.siteInfo?.redirects || []) .catch((e) => Promise.reject(e)); }