Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Ajax requests with X-CSRF header #98

Closed
wants to merge 8 commits into from
Closed

Add support for Ajax requests with X-CSRF header #98

wants to merge 8 commits into from

Conversation

odan
Copy link

@odan odan commented Mar 11, 2019

This PR will add support for Ajax requests with X-CSRF http headers.

Currentlythe header names X-CSRF-NAME and X-CSRF-VALUE are fixed and not configurable. If necessary, this could be added later.

Usage

Twig and jQuery

Example:

<script>
    $.ajaxSetup({
        beforeSend: function (xhr) {
            xhr.setRequestHeader("X-CSRF-NAME", "{{ csrf.name }}");
            xhr.setRequestHeader("X-CSRF-VALUE", "{{ csrf.value }}");
        }
    });
</script>

@odan odan closed this Apr 6, 2019
@xenogenesi xenogenesi mentioned this pull request Sep 21, 2020
@blizzz blizzz mentioned this pull request Jan 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant