spotify-api.js icon indicating copy to clipboard operation
spotify-api.js copied to clipboard

fix(auth): ensure to set proper "Content-Type" HTTP request header

Open leonklingele opened this issue 1 year ago • 1 comments

When not specifying a "data" property for HTTP requests, Axios uses a "Content-Type: application/json" header, even if another "Content-Type" header was specified. This makes these requests to the Spotify API fail with a response status of 400 and a response body of

{"error":"server_error"}

This change sets an empty "data" property to make Axios send the "Content-Type: application/x-www-form-urlencoded" header as expected.

I spent quite a bit of time on debugging this, until I found https://github.com/spotify/web-api/issues/449#issuecomment-312677019

leonklingele avatar Jan 19 '25 22:01 leonklingele

thanks for the fix @leonklingele ,it works perfectly !

would it be possible to merge this PR @scientific-dev ?

jjanvier avatar May 10 '25 12:05 jjanvier