From aa45acf9fda2eabd08daddda7fbf91534eb3a872 Mon Sep 17 00:00:00 2001 From: David Glick Date: Wed, 8 May 2024 12:14:36 -0700 Subject: [PATCH 1/2] Revert "Fix 301 and 302 redirects. (#6001)" This reverts commit 15f342e92c10d9557296c7c468a09afd95924725. --- src/components/theme/View/View.jsx | 5 ----- src/helpers/Api/Api.js | 2 +- src/helpers/Api/Api.plone.rest.test.js | 14 ++++++-------- src/helpers/Api/Api.test.js | 14 ++++++-------- 4 files changed, 13 insertions(+), 22 deletions(-) diff --git a/src/components/theme/View/View.jsx b/src/components/theme/View/View.jsx index e9e148265d..0fb916922b 100644 --- a/src/components/theme/View/View.jsx +++ b/src/components/theme/View/View.jsx @@ -206,11 +206,6 @@ class View extends Component { if (this.props.error && this.props.error.code === 301) { const redirect = flattenToAppURL(this.props.error.url).split('?')[0]; return ; - } else if (this.props.error && this.props.error.status === 302) { - const redirect = flattenToAppURL( - this.props.error.response.header.location, - ).split('?')[0]; - return ; } else if (this.props.error && !this.props.connectionRefused) { let FoundView; if (this.props.error.status === undefined) { diff --git a/src/helpers/Api/Api.js b/src/helpers/Api/Api.js index 4a5c81d546..c91a667ea4 100644 --- a/src/helpers/Api/Api.js +++ b/src/helpers/Api/Api.js @@ -54,7 +54,7 @@ class Api { ) => { let request; let promise = new Promise((resolve, reject) => { - request = superagent[method](formatUrl(path)).redirects(0); + request = superagent[method](formatUrl(path)); if (params) { request.query(params); diff --git a/src/helpers/Api/Api.plone.rest.test.js b/src/helpers/Api/Api.plone.rest.test.js index 81fa1104b2..80e18682d1 100644 --- a/src/helpers/Api/Api.plone.rest.test.js +++ b/src/helpers/Api/Api.plone.rest.test.js @@ -3,14 +3,12 @@ import Api from './Api'; jest.mock('superagent', () => ({ get: jest.fn((url) => ({ - redirects: jest.fn(() => ({ - url, - query: jest.fn(), - set: jest.fn(), - type: jest.fn(), - send: jest.fn(), - end: jest.fn(), - })), + url, + query: jest.fn(), + set: jest.fn(), + type: jest.fn(), + send: jest.fn(), + end: jest.fn(), })), })); diff --git a/src/helpers/Api/Api.test.js b/src/helpers/Api/Api.test.js index 2cd2bcd6bb..c877f1724f 100644 --- a/src/helpers/Api/Api.test.js +++ b/src/helpers/Api/Api.test.js @@ -9,14 +9,12 @@ import Api from './Api'; jest.mock('superagent', () => ({ get: jest.fn((url) => ({ - redirects: jest.fn(() => ({ - url, - query: jest.fn(), - set: jest.fn(), - type: jest.fn(), - send: jest.fn(), - end: jest.fn(), - })), + url, + query: jest.fn(), + set: jest.fn(), + type: jest.fn(), + send: jest.fn(), + end: jest.fn(), })), })); From ade48fe25895c941e9f7e2b9b29db596cf28e3be Mon Sep 17 00:00:00 2001 From: David Glick Date: Wed, 8 May 2024 12:16:40 -0700 Subject: [PATCH 2/2] changelog --- news/6009.bugfix | 1 + 1 file changed, 1 insertion(+) create mode 100644 news/6009.bugfix diff --git a/news/6009.bugfix b/news/6009.bugfix new file mode 100644 index 0000000000..246db35987 --- /dev/null +++ b/news/6009.bugfix @@ -0,0 +1 @@ +Revert "Fix 301 and 302 redirects" which was not working correctly. @davisagli