{"action":"closed","issue":{"url":"https://api.github.com/repos/expressjs/csurf/issues/109","repository_url":"https://api.github.com/repos/expressjs/csurf","labels_url":"https://api.github.com/repos/expressjs/csurf/issues/109/labels{/name}","comments_url":"https://api.github.com/repos/expressjs/csurf/issues/109/comments","events_url":"https://api.github.com/repos/expressjs/csurf/issues/109/events","html_url":"https://github.com/expressjs/csurf/issues/109","id":191990937,"number":109,"title":"Ajax token","user":{"login":"tomek121","id":23703913,"avatar_url":"https://avatars.githubusercontent.com/u/23703913?v=3","gravatar_id":"","url":"https://api.github.com/users/tomek121","html_url":"https://github.com/tomek121","followers_url":"https://api.github.com/users/tomek121/followers","following_url":"https://api.github.com/users/tomek121/following{/other_user}","gists_url":"https://api.github.com/users/tomek121/gists{/gist_id}","starred_url":"https://api.github.com/users/tomek121/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tomek121/subscriptions","organizations_url":"https://api.github.com/users/tomek121/orgs","repos_url":"https://api.github.com/users/tomek121/repos","events_url":"https://api.github.com/users/tomek121/events{/privacy}","received_events_url":"https://api.github.com/users/tomek121/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-11-28T12:13:18Z","updated_at":"2017-01-30T01:06:48Z","closed_at":"2017-01-30T01:06:48Z","body":"Hello,\r\n\r\nI have a little problem when I am doing AJAX post.\r\n\r\nMy Ajax configuration: \r\n\r\n```\r\n    $.ajaxSetup({\r\n        headers: {'X-CSRF-Token': $(\"#_csrf\").attr(\"value\")}\r\n    });\r\n```\r\nMy ajax functions:\r\n\r\n```\r\nfunction deletefile(x){\r\n$.ajax({\r\n                                          url: '/delete',\r\n                                          type: 'POST',\r\n                                          data: {filenameanddirectory:x1},\r\n                                          success: function(data){....}\r\n       \r\n     });}\r\n```\r\n```\r\nfunction uploadphotoF(x) {\r\n$.ajax({\r\n                                          url: '/upload',\r\n                                          type: 'POST',\r\n                                          data: {filenameanddirectory:x1},\r\n                                          success: function(data){....}\r\n       \r\n     });}\r\n```\r\n\r\nAs you see I am using two routes to upload and delete file. When I am uploading files it works correctly as ajax setup has proper token. When I want to delete the file (second route is being called without reloading the page) then I have an error invalid token. \r\n\r\nThe question is if there is any solution for that. I know that in callback of ajax I can change the field which stores token value on each ajax call but is it safe?\r\n"}}
{"actor":{"display_login":"dougwilson"}}