Добавление заголовка против CSRF ко всем AJAX запросам JQuery

remotes/origin/hasaccess
Vitaly Baev 8 years ago
parent 719fa0fe5e
commit 1743f8cc23
  1. 1
      project/templates/lilcity/index.html
  2. 1
      web/src/js/app.js
  3. 10
      web/src/js/modules/common.js

@ -25,6 +25,7 @@
<meta property="og:description" content="Description Here">
<meta property="og:site_name" content="Site Name, i.e. Moz">
<meta property="fb:admins" content="Facebook numeric ID">
<meta name="csrf-token" content="{{ csrf_token }}">
<link rel="stylesheet" media="all" href={% static "css/app.css" %}>
<script>
var viewportmeta = document.querySelector('meta[name="viewport"]');

@ -2,6 +2,7 @@
* Входная точка клиентского приложения.
*/
import "./modules/common";
import "./modules/header";
import "./modules/search";
import "./modules/toggle";

@ -0,0 +1,10 @@
import $ from 'jquery';
$(document).ready(function () {
// Добавляем заголовок X-CSRFToken для всех AJAX запросов JQuery.
$.ajaxSetup({
headers: {
'X-CSRFToken': $('meta[name="csrf-token"]').attr('content')
}
});
});
Loading…
Cancel
Save