Laravel: Automatically send CSRF token with requests in vanilla JS
问题 I use a package installed with Composer in my Laravel project. It contains some JS code for file uploads. In at least one case, the uploads fail because there is no CSRF token sent with the request. I hope to solve this problem without editing the vendor code. This is the relevant JS: self.upload = function (file, filename) { var formData = new FormData(); formData.append('file', file, filename); formData.append('field', JSON.stringify(field)); formData.append('contentId', H5PEditor.contentId