cancel
Showing results for 
Search instead for 
Did you mean: 

Magento 2.3.5: Showing Invalid Form key on every page

Magento 2.3.5: Showing Invalid Form key on every page

Hi,

 

We are facing an issue after upgrading Magento version to 2.3.5.

Invalid form key. Please refresh the page.  is showing on every page only on safari browser.

6 REPLIES 6

Re: Magento 2.3.5: Showing Invalid Form key on every page

Hi @mandar_parbate1 
If this issue is only coming on Safari browser try clearing all the cache on the browser and check again.

Also can you confirm from which version of magento 2 you have done upgrade to magento 2.3.5?

Re: Magento 2.3.5: Showing Invalid Form key on every page

im using 2.3.5-p1. facing same error.

Re: Magento 2.3.5: Showing Invalid Form key on every page

Hi

Facing the same issue here.

Invalid Form Key. Please refresh the page.

Magento ver. 2.3.5-p1

Safari only.

I've changed to developer mode.

Cleaned all directories with

rm -rf var/di/* var/generation/* var/cache/* var/log/* var/page_cache/* var/session/* var/view_preprocessed/*
Changed back to production mode
Cleared cache
Nothing works.
Getting reports from customers that this is showing on their system also.
Is anyone looking into this?

Re: Magento 2.3.5: Showing Invalid Form key on every page

CSP is not setup correctly.  Either fix csp or disable it:

 

php bin/magento module:disable Magento_Csp

Re: Magento 2.3.5: Showing Invalid Form key on every page

I try to disable this module using your command.
It says:
-bash: magento: command not found

Re: Magento 2.3.5: Showing Invalid Form key on every page

In my case, this was caused by a typo in a template file.

 

In my theme's template, Magento_Review/templates/review.phtml:

 

<script type="text/x-magento-init">
    {
        "*": {
            "Magento_Review/js/process-reviews": {
                "productReviewUrl": <?= $block->escapeJs($block->getProductReviewUrl()) ?>",
                "reviewsTabSelector": "#tab-label-reviews"
            }
        }
    }
</script>

There's a missing double quote, and it should look like this:

<script type="text/x-magento-init">
    {
        "*": {
            "Magento_Review/js/process-reviews": {
                "productReviewUrl": "<?= $block->escapeJs($block->getProductReviewUrl()) ?>",
                "reviewsTabSelector": "#tab-label-reviews"
            }
        }
    }
</script>

After adding that double quote, the JS for Add to Cart populates with the correct Form Key, and all is good.