The approach suggested by @4k4 might be correct, I did not test
How do I display a modal dialog on page load, with working title and dialog options, using OpenModalDialogCommand?
What I did:
This is not a good solution for me.
Gàbor's answer with middleware implementation is perfect, thanks to him !
But I encountered the following error, introduced by PHP 7.4 properties type-hinting :
Error: Typed property Drupal\your_module\Middleware\Redirect::$redirectResponse must not be accessed before initialization.
I first tried to add RedirectResponse as an argument to the service and ...