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);

https://drupal.stackexchange.com/questions/223482/force-redirect-in-submit-handler-even-though-destination-parameter-set

" 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

https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Routing%21CacheableSecuredRedirectResponse.php/class/CacheableSecuredRedirectResponse/8.6.x

https://api.drupal.org/api/drupal/vendor%21symfony%21http-kernel%21Event%21GetResponseEvent.php/class/GetResponseEvent/8.6.x

drupal_goto() has been removed https://www.drupal.org/node/2023537

https://x-team.com/blog/drupal-goto/

https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Routing%21UrlGeneratorTrait.php/function/UrlGeneratorTrait%3A%3Aredirect/8.6.x

Redirect to external URLs now requires a special object https://www.drupal.org/node/2532212

https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Routing%21RedirectDestination.php/class/RedirectDestination/8.6.x

Destination URL breaks preview https://www.drupal.org/node/2325463

https://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.4

https://github.com/guzzle/guzzle