diff --git a/src/Authentication/Provider/ApiKeyAuth.php b/src/Authentication/Provider/ApiKeyAuth.php
index c2ed495655f74cd8911ed1636c0e9e4458bb735b..923439c5bfae299828609ca99c0a1be5dae94477 100644
--- a/src/Authentication/Provider/ApiKeyAuth.php
+++ b/src/Authentication/Provider/ApiKeyAuth.php
@@ -123,7 +123,7 @@ class ApiKeyAuth implements AuthenticationProviderInterface {
   public function getKey(Request $request) {
     // Exempt edit/delete form route.
     $route_name = $this->currentRouteMatch->getRouteName();
-    if (strstr($route_name, 'entity.api_key')) {
+    if (str_contains($route_name ?? '', 'entity.api_key')) {
       return FALSE;
     }