@plone/volto 17.18.1 → 17.18.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -17,6 +17,12 @@ myst:
17
17
 
18
18
  <!-- towncrier release notes start -->
19
19
 
20
+ ## 17.18.2 (2024-07-10)
21
+
22
+ ### Bugfix
23
+
24
+ - Return a redirect response from Volto server-side rendering if the API request was redirected. @JeffersonBledsoe @mamico [#4854](https://github.com/plone/volto/issues/4854)
25
+
20
26
  ## 17.18.1 (2024-06-29)
21
27
 
22
28
  ### Bugfix
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  }
10
10
  ],
11
11
  "license": "MIT",
12
- "version": "17.18.1",
12
+ "version": "17.18.2",
13
13
  "repository": {
14
14
  "type": "git",
15
15
  "url": "git@github.com:plone/volto.git"
@@ -187,7 +187,8 @@
187
187
  "hooks": {
188
188
  "before:bump": [
189
189
  "yarn i18n",
190
- "yarn build:types"
190
+ "yarn build:types",
191
+ "git add types"
191
192
  ],
192
193
  "after:bump": [
193
194
  "pipx run towncrier build --draft --yes --version ${version} > .changelog.draft && pipx run towncrier build --yes --version ${version}",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plone/volto-slate",
3
- "version": "17.18.1",
3
+ "version": "17.18.2",
4
4
  "description": "Slate.js integration with Volto",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: IDM2 A-Team",
@@ -205,8 +205,10 @@ class View extends Component {
205
205
  */
206
206
  render() {
207
207
  const { views } = config;
208
- if (this.props.error && this.props.error.code === 301) {
209
- const redirect = flattenToAppURL(this.props.error.url).split('?')[0];
208
+ if ([301, 302].includes(this.props.error?.code)) {
209
+ const redirect = flattenToAppURL(this.props.error.url)
210
+ .split('?')[0]
211
+ .replace('/++api++', '');
210
212
  return <Redirect to={`${redirect}${this.props.location.search}`} />;
211
213
  } else if (this.props.error && !this.props.connectionRefused) {
212
214
  let FoundView;
@@ -22,6 +22,7 @@ beforeAll(() => {
22
22
  });
23
23
  config.settings.publicURL = 'https://plone.org';
24
24
  });
25
+ global.__SERVER__ = true; // eslint-disable-line no-underscore-dangle
25
26
 
26
27
  const mockStore = configureStore();
27
28
 
@@ -80,6 +80,10 @@ class Api {
80
80
 
81
81
  Object.keys(headers).forEach((key) => request.set(key, headers[key]));
82
82
 
83
+ if (__SERVER__ && checkUrl && ['get', 'head'].includes(method)) {
84
+ request.redirects(0);
85
+ }
86
+
83
87
  if (data) {
84
88
  request.send(data);
85
89
  }
@@ -104,6 +108,14 @@ class Api {
104
108
  url: request.xhr.responseURL,
105
109
  });
106
110
  }
111
+
112
+ if ([301, 302].includes(err?.status)) {
113
+ return reject({
114
+ code: err.status,
115
+ url: err.response.headers.location,
116
+ });
117
+ }
118
+
107
119
  return err ? reject(err) : resolve(response.body || response.text);
108
120
  });
109
121
  });
@@ -18,6 +18,7 @@ beforeAll(() => {
18
18
 
19
19
  const api = new Api();
20
20
  const { settings } = config;
21
+ global.__SERVER__ = true; // eslint-disable-line no-underscore-dangle
21
22
 
22
23
  test('get request', () => {});
23
24
 
@@ -24,6 +24,7 @@ beforeAll(() => {
24
24
 
25
25
  const api = new Api();
26
26
  const { settings } = config;
27
+ global.__SERVER__ = true; // eslint-disable-line no-underscore-dangle
27
28
 
28
29
  test('get request', () => {});
29
30