Skip to main content
Updated doc URL
Source Link
Brandon Kelly
  • 34.4k
  • 2
  • 74
  • 139

In Craft 3 the csrf token validation in the general.php config is set to true by default. In order to request your controller with post requests you have to turn it off or include the token

https://github.com/craftcms/docs/blob/v3/en/changes-in-craft-3.md#csrf-token-paramshttps://docs.craftcms.com/v3/changes-in-craft-3.html#csrf-token-params

{% set csrfTokenName = craft.app.config.general.csrfTokenName %}         
{% set csrfToken = craft.app.request.csrfToken %}     
<input type="hidden" name="{{ csrfTokenName }}" value="{{ csrfToken }}">

In Craft 3 the csrf token validation in the general.php config is set to true by default. In order to request your controller with post requests you have to turn it off or include the token

https://github.com/craftcms/docs/blob/v3/en/changes-in-craft-3.md#csrf-token-params

{% set csrfTokenName = craft.app.config.general.csrfTokenName %}         
{% set csrfToken = craft.app.request.csrfToken %}     
<input type="hidden" name="{{ csrfTokenName }}" value="{{ csrfToken }}">

In Craft 3 the csrf token validation in the general.php config is set to true by default. In order to request your controller with post requests you have to turn it off or include the token

https://docs.craftcms.com/v3/changes-in-craft-3.html#csrf-token-params

{% set csrfTokenName = craft.app.config.general.csrfTokenName %}         
{% set csrfToken = craft.app.request.csrfToken %}     
<input type="hidden" name="{{ csrfTokenName }}" value="{{ csrfToken }}">
Source Link
Robin Schambach
  • 19.8k
  • 1
  • 20
  • 45

In Craft 3 the csrf token validation in the general.php config is set to true by default. In order to request your controller with post requests you have to turn it off or include the token

https://github.com/craftcms/docs/blob/v3/en/changes-in-craft-3.md#csrf-token-params

{% set csrfTokenName = craft.app.config.general.csrfTokenName %}         
{% set csrfToken = craft.app.request.csrfToken %}     
<input type="hidden" name="{{ csrfTokenName }}" value="{{ csrfToken }}">