diff --git a/src/Form/VerifyEmailForm.php b/src/Form/VerifyEmailForm.php
index f458e72ef02f3516480bf0506d3dbb8d0ae4cca6..7d518eac68694b898327c843ec602956e344d086 100644
--- a/src/Form/VerifyEmailForm.php
+++ b/src/Form/VerifyEmailForm.php
@@ -8,7 +8,6 @@
 use Drupal\Core\Form\FormBase;
 use Drupal\Core\Form\FormStateInterface;
 use Drupal\Core\Session\AccountProxyInterface;
-use Drupal\Core\Url;
 use Drupal\verify_email\Service\VerifierInterface;
 use Drupal\verify_email\VerifyEmailInterface;
 use Symfony\Component\DependencyInjection\ContainerInterface;
@@ -101,7 +100,7 @@ public function submitForm(array &$form, FormStateInterface $form_state): void {
     $this->messenger()->addStatus($this->t('The message has been sent.'));
 
     // Redirect to the 'thank you' page of the specific entity.
-    $form_state->setRedirectUrl(Url::fromRoute('verify_email.' . $entity->id() . '.thanks'));
+    $form_state->setRedirect('verify_email.' . $entity->id() . '.thanks');
   }
 
 }