Skip to content

Commit

Permalink
feat: adds an ability to change CSRF header name
Browse files Browse the repository at this point in the history
  • Loading branch information
Avol-V committed Jul 26, 2024
1 parent 597cb6f commit c8c20b6
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/utils/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ export default class Api extends AxiosWrapper {
const {config} = error;

if (config && !config[csrfRetryKey] && error.response?.status === 419) {
if (error.response.headers['x-csrf-token']) {
this.setCSRFToken(error.response.headers['x-csrf-token']);
const csrfHeaderName = (this.csrfHeaderName || 'x-csrf-token').toLowerCase();

if (error.response.headers[csrfHeaderName]) {
this.setCSRFToken(error.response.headers[csrfHeaderName]);
}

return this._axios({
Expand Down

0 comments on commit c8c20b6

Please sign in to comment.