1

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)"} []

asked Jun 16, 2020 at 10:52
4
  • 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. Commented Jun 16, 2020 at 11:09
  • yes @VivekKumar error addedd Commented Jun 16, 2020 at 11:39
  • can you add url here where you get this error and menu.xml file for the same ? Commented Jun 16, 2020 at 15:41
  • This error is in debug.log not in any console or network error Commented Jun 16, 2020 at 19:40

1 Answer 1

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)"} []

answered Feb 4, 2021 at 11:53
0

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.