Read CSRF token from DOM instead of cookie

Fixes #307
This commit is contained in:
David Neale 2017-10-30 16:34:40 +00:00 committed by GitHub
parent 2600f0f041
commit 189a586cfb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -23,12 +23,10 @@ add "&raw" to the end of the URL within a browser.
<script src="//cdn.jsdelivr.net/graphiql/{{graphiql_version}}/graphiql.min.js"></script>
</head>
<body>
{% csrf_token %}
<script>
// Parse the cookie value for a CSRF token
var csrftoken;
var cookies = ('; ' + document.cookie).split('; csrftoken=');
if (cookies.length == 2)
csrftoken = cookies.pop().split(';').shift();
var csrftoken = document.querySelector("[name=csrfmiddlewaretoken]").value;
// Collect the URL parameters
var parameters = {};