AXIOS wrongly changing 'content-type' header value

Viewed 31

The problem: I am using AXIOS to make POST requests and the API I am interacting with requires the data to be sent as an URL encoded string. I use a package which converts all of the data and parameters into an URL encoded string, this package is called query-string. I manually set the header.content-type value to 'application/x-www-form-urlencoded'. However, when the request is triggered, AXIOS changes the content-type value to 'multipart/form-data', this causes the API I am interacting with to error due to the data and parameters not being formatted in a way it expects.

What I have tried: I have tried using URLSearchParams to convert my data and parameters, and the same thing happens when the request is triggered, the content-type value is changed from 'application/x-www-form-urlencoded' to 'multipart/form-data'.

Extra information that might help

  • We deployed last week and AXIOS managed to make requests which did not change the content-type for a couple of days, however it has now changed it's behaviour and is changing the content-type value.

  • This content-type changing problem only occurs in the deployed version, when I run the app locally I cannot recreated the issue.

Thank you for your time.

0 Answers
Related