rails / request.js

MIT License
389 stars 28 forks source link

Do not send CSRF token for external requests #46

Closed t27duck closed 2 years ago

t27duck commented 2 years ago

This library could be used for any AJAX request, however it was reported that some 3rd party endpoints reject the request if the CSRF token is included in the headers.

This change excludes the CSRF token from the headers by comparing the request URL and window.location.hostname.

I beleive this covers and maintains the existing expectations of the library so existing applications shouldn't be caught off gaurd as we are including the token more often than not.

Closes #45