From 09239bfde86c7dff628c7aec3df291d439dab33c Mon Sep 17 00:00:00 2001 From: David Glick Date: Wed, 8 May 2024 12:56:39 -0700 Subject: [PATCH] Revert "Fix 301 and 302 redirects. (#5999)" (#6008) --- packages/volto/news/5999.bugfix | 1 - packages/volto/src/components/theme/View/View.jsx | 5 ----- packages/volto/src/helpers/Api/Api.js | 2 +- .../volto/src/helpers/Api/Api.plone.rest.test.js | 14 ++++++-------- packages/volto/src/helpers/Api/Api.test.js | 14 ++++++-------- 5 files changed, 13 insertions(+), 23 deletions(-) delete mode 100644 packages/volto/news/5999.bugfix diff --git a/packages/volto/news/5999.bugfix b/packages/volto/news/5999.bugfix deleted file mode 100644 index 949e8b88f7..0000000000 --- a/packages/volto/news/5999.bugfix +++ /dev/null @@ -1 +0,0 @@ -Fix 301 and 302 redirects. @robgietema \ No newline at end of file diff --git a/packages/volto/src/components/theme/View/View.jsx b/packages/volto/src/components/theme/View/View.jsx index f841cdcbb7..418897e5f0 100644 --- a/packages/volto/src/components/theme/View/View.jsx +++ b/packages/volto/src/components/theme/View/View.jsx @@ -209,11 +209,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/packages/volto/src/helpers/Api/Api.js b/packages/volto/src/helpers/Api/Api.js index 4a5c81d546..c91a667ea4 100644 --- a/packages/volto/src/helpers/Api/Api.js +++ b/packages/volto/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/packages/volto/src/helpers/Api/Api.plone.rest.test.js b/packages/volto/src/helpers/Api/Api.plone.rest.test.js index 81fa1104b2..80e18682d1 100644 --- a/packages/volto/src/helpers/Api/Api.plone.rest.test.js +++ b/packages/volto/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/packages/volto/src/helpers/Api/Api.test.js b/packages/volto/src/helpers/Api/Api.test.js index 2cd2bcd6bb..c877f1724f 100644 --- a/packages/volto/src/helpers/Api/Api.test.js +++ b/packages/volto/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(), })), }));