Skip to content

Commit aa74fcb

Browse files
jessarchertaylorotwell
authored andcommitted
Remove manual adding of X-CSRF-TOKEN header (laravel#5083)
This is unnessecery code because Axios already automatically adds a X-XSRF-TOKEN header from the XSRF-TOKEN cookie encrypted value on same-origin requests. The `VerifyCsrfToken` middleware and Passport's `TokenGuard` already allow using the `X-XSRF-TOKEN` header.
1 parent b84bcc6 commit aa74fcb

File tree

1 file changed

+0
-14
lines changed

1 file changed

+0
-14
lines changed

resources/js/bootstrap.js

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,6 @@ window.axios = require('axios');
2323

2424
window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
2525

26-
/**
27-
* Next we will register the CSRF Token as a common header with Axios so that
28-
* all outgoing HTTP requests automatically have it attached. This is just
29-
* a simple convenience so we don't have to attach every token manually.
30-
*/
31-
32-
let token = document.head.querySelector('meta[name="csrf-token"]');
33-
34-
if (token) {
35-
window.axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content;
36-
} else {
37-
console.error('CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token');
38-
}
39-
4026
/**
4127
* Echo exposes an expressive API for subscribing to channels and listening
4228
* for events that are broadcast by Laravel. Echo and event broadcasting

0 commit comments

Comments
 (0)