Problem
We have redirection logic that routes to the backend, whenever an URL is accessed that shall render into custom_elements but does not support it.
Example:
https://lupus-decoupled.ddev.site/ce-api/user/logout/confirm
->
Redirects to https://lupus-decoupled.ddev.site/ce-api/user/logout/confirm
That example works good.
However, when there is a route which has is specified to be of format custom_elements, but was not requested like this, then the same happens. Then the redirect is
/route-with-format-ce-but-no-ce-response --> redirects to /route-with-format-ce-but-no-ce-response
This does not make sense.
Steps to reproduce
Define new route with _format = custom_elements
Return render array without CE.
Open it.
Proposed resolution
To avoid this, we shall not apply the redirect if there is only one single format registered for the given route AND the format is custom_elements. In that case we could even force-render it with custom-elements, since it was defined like this, or error out.
Remaining tasks
Solve and write test coverage
Issue fork lupus_ce_renderer-3519996
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
fagoWith lupus_csr this also happens more frequently, e.g. /user/logout/confirm route opened in frontend triggers API to /ce-api//user/logout/confirm what is not support ce-format, thus renders a redirect to /user/logout/confirm
First off, we only want this redirect if the target route is an admin route.
Comment #3
fagoAssuming the admin route is not rendered with a decoupled frontend, this works. but when it is we have an endless loop again!
Comment #5
fagoComment #6
fagoadded a new MR. It also improves things for cases where route-negotation failed and created 406 responses. Previously we failed to redirect them. Thus, it covers the following-cases now, including test coverage:
- _admin_route flagged routes (e.g. /node/1/edit, /admin) → redirect
- _admin_route flagged + _format: html routes (e.g. /batch) → redirect via on406
- Admin-themed via negotiation + _format: html → redirect via on406
- Non-admin + _format: html → 406 error page
- Non-admin render arrays → rendered as custom elements
- Drupal core redirects (e.g. /user → /user/{id}) → redirect preserved
- admin route with custom_elements support does not redirect, but renders
We still have the issue that an admin-page rendering /ce-api/node/1/edit would run into an endless-loop, but that's by-design. admin routes should not be rendering via the decoupled frontend and thus not trigger /ce-api. When the frontend does that, the redirect is exactly what we want.
User-facing routes like /user/logout/confirm work fine now and have no redirect loop any more.
Comment #8
fago