How to redirect custom ajax form to external url
You can't return a redirect response, because the ajax script in the browser expects a json array with jquery commands, so you need to return a RedirectCommand from the ajax callback:

  public function ajaxCallback(array &amp;$form, FormStateInterface $form_state) {
    $response = new AjaxResponse();

    $command = new RedirectCommand('https://example.com');

    return $response-&gt;addCommand($command);
  }


which then assigns window.location to redirect client-side.