can you please suggest me I have transferred my site from one server to another, all Magento functionality works except add to cart.
And checkout cart add controller return 500 error
I am getting below error in debug.log
Request validation failed for action "Magento\Framework\App\Action\Forward\Interceptor" {"exception":"[object] (Magento\Framework\App\Request\InvalidRequestException(code: 0): Invalid request received at /home/simplecity/public_html/vendor/magento/framework/App/Request/CsrfValidator.php:105)"} []
- 
 Please add the error you're getting, check error and systemlog. Check in the network and console tab on dev console ito check if you're getting any error there.Vivek Kumar– Vivek Kumar2020年06月16日 11:09:17 +00:00Commented Jun 16, 2020 at 11:09
- 
 yes @VivekKumar error addeddSanjay Shiyal– Sanjay Shiyal2020年06月16日 11:39:28 +00:00Commented Jun 16, 2020 at 11:39
- 
 can you add url here where you get this error and menu.xml file for the same ?ParulThakkar– ParulThakkar2020年06月16日 15:41:18 +00:00Commented Jun 16, 2020 at 15:41
- 
 This error is in debug.log not in any console or network errorSanjay Shiyal– Sanjay Shiyal2020年06月16日 19:40:26 +00:00Commented Jun 16, 2020 at 19:40
1 Answer 1
I Ignored Validation use plugin as below :
Module_Name/etc/di.xml add:
<type name="Magento\Framework\App\Request\CsrfValidator">
 <plugin name="csrf_validator_skip" type="Module\Name\Plugin\CsrfValidatorSkip" />
</type>
Module_Name/Plugin/CsrfValidatorSkip.php
namespace Module\Name\Plugin;
class CsrfValidatorSkip
{
 /**
 * @param \Magento\Framework\App\Request\CsrfValidator $subject
 * @param \Closure $proceed
 * @param \Magento\Framework\App\RequestInterface $request
 * @param \Magento\Framework\App\ActionInterface $action
 */
 public function aroundValidate(
 $subject,
 \Closure $proceed,
 $request,
 $action
 ) {
 /* Magento 2.1.x, 2.2.x */
 if ($request->getModuleName() == 'name') {
 return; // Skip CSRF check
 }
 $proceed($request, $action); // Proceed Magento 2 core functionalities
 }
}
My Error was as below:
main.DEBUG: Request validation failed for action "Module\Name\Controller\HtmlRedirect\Response\Interceptor" {"exception":"[object] (Magento\Framework\App\Request\InvalidRequestException(code: 0): Invalid request received at MagentoRoot/vendor/magento/framework/App/Request/CsrfValidator.php:105)"} []