Preserve X-Xsrf-Token header from .htaccess #6520
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In .htaccess file right now we have rewrite rule to preserve Authorization header. That commit exists in .htaccess file since 2016, which was later updated.
Laravel uses X-XSRF-TOKEN for session based authentication in API and just like Authorization header is sometimes removed by some of the server configurations (Typically on shared hosting) X-XSRF-TOKEN is also removed and to properly implement session based authentication with Laravel API, the header needs to be preserved.
I came to this change when I tried to deploy my Laravel API into shared hosting and authorization did not work because X-XSRF-TOKEN was removed by server configuration and on shared hosting typically we do not have control on the server configuration.
I think this change will not affect anything else, other than it makes sure that X-XSRF-TOKEN header is always preserved and passed to Laravel.
I would be happy to write any tests to support the PR, but I think this particular change is the type of change for which you can not write any tests.