diff --git a/docs/csrf.rst b/docs/csrf.rst index d9a8ff6e..088809c9 100644 --- a/docs/csrf.rst +++ b/docs/csrf.rst @@ -54,6 +54,10 @@ token in the form. +Be careful to write the ``name`` attribute of the input tag as it is, with an underscore. +If CSRF protection is enabled and the name does not match with the value of ``WTF_CSRF_FIELD_NAME`` (whose default value is ``'csrf_token'``), you get the Bad Request: CSRF token missing error. +If you want to use something else as the name attribute (although not recommended), ensure to set the ``WTF_CSRF_FIELD_NAME`` to ``'anyStringYouWant'`` in your app config. + JavaScript Requests ------------------- @@ -82,6 +86,34 @@ In Axios you can set the header for all requests with ``axios.defaults.headers.c axios.defaults.headers.common["X-CSRFToken"] = "{{ csrf_token() }}"; +To send the form data of other form inputs to your backend route using Vanilla Js for example. + +.. sourcecode:: html+jinja + + + Customize the error response ----------------------------