Alter existing 'Log In' route so URL includes request_uri as query string
I think you'll need to have a look to PathProcessors, you might do something like that:
mymodule/mymodule.services.yml
mymodule.path_processor:
  class: Drupal\mymodule\PathProcessor\MymodulePathProcessor
  tags:
    - { name: path_processor_inbound, priority: 250 }

mymodule/src/PathProcessor/MymodulePathProcessor
&lt;?php

namespace Drupal\mymodule\PathProcessor;

use Drupal\Core\PathProcessor\InboundPathProcessorInterface;
use Symfony\Component\HttpFoundation\Request;

/**
 * Class MymodulePathProcessor.
 *
 * @package Drupal\mymodule\PathProcessor
 */
class MymodulePathProcessor implements InboundPathProcessorInterface {
  
  /**
   * {@inheritdoc}
   */
  public function processInbound($path, Request $request) {
    if ($path == '/user/login') {
      $request_uri = $request-&gt;server-&gt;get('REQUEST_URI');
      return &quot;/login?destination={$request_uri}&quot;;
    }
  }
}

Don't forget to clear the cache before to try it.
You might need the processOutbound function too in which case you'll need one more line in your service
mymodule/mymodule.services.yml
mymodule.path_processor:
  class: Drupal\mymodule\PathProcessor\MymodulePathProcessor
  tags:
    - { name: path_processor_inbound, priority: 250 }
    - { name: path_processor_outbound, priority: 250 }