Volto Alternate Link (redirect) returns error 500 [Solved]

Hey community,

So I tried the following:

  1. Create a page with id "test"

  2. Rename that page to id "test2"

  3. Browser /test

In debug mode, I got an error 500 on the first call (document) so I guess it was something that failed on the server. And then a redirect is performed to test2

In production mode, the error is generated and nothing more happens.

GET http://localhost:3005/test 500 (Internal Server Error)

Environment:

  • Volto 17.12.1 generated with generator-volto 8.1.3

  • Plone 6.0.9 with plone.restapi 9.2.1

When I try this on the demo site it works well: https://demo.plone.org/test

So I tried to delete all addons of my project and change volto version to 17.15.5 but the same behavior as before.

On debugging, putting some console logs here and there, I found that the error on middleware is the following:

error in middleware TypeError: Cannot read properties of undefined (reading 'actions')
    at actions ({...}/node_modules/@plone/volto/src/reducers/actions/actions.js:53:1)

Then after more debugging, in src/middleware/storeProtectLoadUtils.js I found that first the test2 object info is obtained in:

{ subrequest: null, result: {INFO test-2 object}, type: 'GET_CONTENT_SUCCESS' }

but later, another action with an empty result is executed which produces the error on the reducers (on action reducer and if I modify that reducer, in breadcrumbs and so on)

{ subrequest: null, result: {}, type: 'GET_CONTENT_SUCCESS' }

Any idea what is going wrong on here and why this is not happening on the demo site?

I will try to create a fresh environment with volto 15.15.5 and see if that's still happening.

Meanwhile, I made this change in src/middleware/storeProtectLoadUtils.js which feels super hacky but avoids the error on the reducers and thus the redirect is made in production mode aswell

export const protectLoadEnd =

    [...]

    if (action?.type === 'GET_CONTENT_SUCCESS' && Object.keys(action?.result).length === 0) {
      return
    }
    return next(action);
  };

Tried with a new installation an a different set of versions:

  • Plone 6.0.10
  • Volto 17.15.5
  • Node 20 / 18
  • Yarn 3.4.1 / 3.6.1

But in all of this I get the 500 (Internal server error). I'm using RAZZLE_PROXY_API_PATH as my plone is not on the default location, but also tried to run volto with a Plone in the default location

I created the volto project in Ubuntu 22 with the follwing commands:

# Install nvm
nvm install 20
nvm use 20
npm install -g yo
npm install -g yarn
yarn set version 3.4.1
npm install -g @plone/generator-volto
yo @plone/volto
# cd to project
yarn install
yarn build
yarn start:prod

No idea what's going wrong, I will report back if I find something more

After more testing with docker images plone/plone-frontend – Install – Containers – Official Images — Plone Documentation v6.0, I saw that the redirects were working correctly there, and it is because its using the RAZZLE_INTERNAL_API_PATH env var in docker-compose.yml.

So now when starting volto either in dev or prod mode if the RAZZLE_INTERNAL_API_PATH is present the 500 errors is not produced anymore and the redirect works as expected

EDIT: Actually if you create a docker-compose.yml without the RAZZLE_INTERNAL_API_PATH the redirects fail