Hi, sorry for my bad english
Problem/Motivation
When response code is defined on 301 or 302, it redirect to the correct link.
When Response code is defined on 403 or 404, then i got a blank page, or a page filled with content of response body.
my question is, why not use the 403 - 404 page specified on Basic site settings -> Error pages (/admin/config/system/site-information) when no response body is set ?
Proposed resolution
This code may not be the best, but it works for me.
Be aware that i've set value on page /admin/config/system/site-information for 403 and 404 field.
in file AccessFilterLegacyMiddleware.php function handle(...)
...
if (in_array($code, [301, 302])) {
return new RedirectResponse($filter->get('parsedResponse')['redirect_url'], $code);
} elseif (empty($filter->get('parsedResponse')['body']) && strcmp($code, 403) == 0 ){
return new RedirectResponse(\Drupal::config('system.site')->get('page.403'));
} elseif (empty($filter->get('parsedResponse')['body']) && strcmp($code, 404) == 0 ){
return new RedirectResponse(\Drupal::config('system.site')->get('page.404'));
} else {
return new Response($filter->get('parsedResponse')['body'], $code);
}
...
thanks for all, and best wishes for the year 2023