Password reset no longer working

Previously I was able to reset password by request a new code to email, but no whenever I try to reset it I got an error “Invalid host domain”

And in the panel log it shows that I have tried to reset the password
01 Jan 2022
16:14:52
Users
Password reset requested (User: abc).

if (in_array(str_replace(':'.$_SERVER['SERVER_PORT'], '.conf', $_SERVER['HTTP_HOST']), array_merge(scandir('/etc/nginx/conf.d'), scandir('/etc/nginx/conf.d/domains'), scandir('/etc/apache2/conf.d/domains'), scandir('/etc/apache2/conf.d')))) {
                    $mailtext .= sprintf(_('PASSWORD_RESET_REQUEST'), $_SERVER['HTTP_HOST'], $user, $rkey, $_SERVER['HTTP_HOST'], $user, $rkey);
                    if (!empty($rkey)) {
                        send_email($to, $subject, $mailtext, $from, $from_name, $data[$user]['NAME']);
                    }
                    header("Location: /reset/?action=code&user=".$_POST['user']);
                    exit;
                } else {
                    $ERROR = "<a class=\"error\">"._('Invalid host domain')."</a>";
                }
            }
        } else {
            $ERROR = "<a class=\"error\">"._('Please wait 15 minutes before sending a new request')."</a>";
        }
    }