Redirect goes to homepage instead of expected location
Turns out this incredibly frustrating developer experience is at least a core bug, albeit one that’s been hanging around for quite a while:
Allow redirects repsonses to override ?destination query parameter https://www.drupal.org/project/drupal/issues/2950883
Workaround to the core bug:
\Drupal::request()->query->remove('destination');
return new TrustedRedirectResponse('https://example.org', 302);
" If the route name is not known use RedirectResponse with a URL. When redirecting to an external location, use TrustedRedirectResponse." https://www.drupal.org/node/2023537
drupal_goto() has been removed https://www.drupal.org/node/2023537
https://x-team.com/blog/drupal-goto/
Redirect to external URLs now requires a special object https://www.drupal.org/node/2532212
Destination URL breaks preview https://www.drupal.org/node/2325463
https://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.4