After Upgrading My Site to Magento version 2.4.3 I am facing this issue on my admin login at 2FA Login screen.
Please Help me About this why its showing the invalid form key.
Magento 2.4.3 has a known bug causing this problem. One user reported your exact problem. From that Github issue, this solution is reported to work until Magento patches this in a future release. I'm unable to paste it here as it doesn't appear to play nice with StackExchange formatting tools, but those links should get you to a solution.
Run below command in terminal Magento root path :
bin/magento module:disable Magento_TwoFactorAuth
bin/magento cache:flush
You have to change default Magento's File
Go to , Magento/Backend/App/Action/Plugin/Authentication.php
find protected function _redirectIfNeededAfterLogin() function
And Replace With Below Code :
protected function _redirectIfNeededAfterLogin(\Magento\Framework\App\RequestInterface $request)
{
$requestUri = null;
// Checks, whether secret key is required for admin access or request uri is explicitly set
if ($this->_url->useSecretKey()) {
$requestParts = strpos(trim($request->getRequestUri(), '/'), $request->getFrontName()) === 0 ?
explode('/', trim($request->getRequestUri(), '/'), 4) :
explode('/', trim($request->getRequestUri(), '/'), 3);
if (($key = array_search($request->getFrontName(), $requestParts)) !== false) {
unset($requestParts[$key]);
}
$requestParams = $request->getParams();
unset($requestParams['key'], $requestParams['form_key']);
$requestUri = $this->_url->getUrl(implode('/', $requestParts), $requestParams);
} elseif ($request) {
$requestUri = $request->getRequestUri();
}
if (!$requestUri) {
return false;
}
$this->_response->setRedirect($requestUri);
$this->_actionFlag->set('', \Magento\Framework\App\ActionInterface::FLAG_NO_DISPATCH, true);
return true;
}
Changes in Default Magento files is not a god practice, until you have to wait Magento official to fix this bug...Or Use this Solution Its Working in my case
Ref : Github