Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v0.27.1 FormData is sent as 'application/x-www-form-urlencoded' instead of 'multipart/form-data' #4627

Closed
TarikAmine opened this issue Apr 26, 2022 · 6 comments

Comments

@TarikAmine
Copy link

TarikAmine commented Apr 26, 2022

Describe the bug

form-data is not correctly sent

To Reproduce

Code snippet to reproduce, ideally that will work by pasting into something like https://npm.runkit.com/axios, a hosted solution, or a repository that illustrates the issue. If your problem is not reproducible, please file under Support or Usage Question

let data = new FormData();
data.append('email', 'foo@bar.com');
axios.post("/test", data)
    .then(function () {
        console.log('OK');
    })
    .catch(function (response) {
        console.log('Error');
    });

Expected behavior

i'm using php so having data available for $_POST

Environment

  • Axios Version 0.27.1 (//unpkg.com/axios@0.27.1/dist/axios.min.js)
  • Adapter HTTP/1.1
  • Browser Firefox
  • Browser Version 99.0 (64 bits)
  • OS: Ubuntu 20.04.4 LTS

Additional context/Screenshots

using 0.27.0 it works

POST /testing HTTP/1.1
Host: example.com
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:99.0) Gecko/20100101 Firefox/99.0
Accept: application/json, text/plain, */*
Accept-Language: fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Content-Type: multipart/form-data; boundary=---------------------------304178265014459940912396198163
Content-Length: 201
Origin: http://example.com
Connection: keep-alive
Referer: http://example.com/test
Pragma: no-cache
Cache-Control: no-cache

-----------------------------304178265014459940912396198163
Content-Disposition: form-data; name="email"

foobar@gmail.com
-----------------------------304178265014459940912396198163--

while 0.27.1 generate this request


POST /testing HTTP/1.1
Host: example.com
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:99.0) Gecko/20100101 Firefox/99.0
Accept: application/json, text/plain, */*
Accept-Language: fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Content-Type: application/x-www-form-urlencoded
Content-Length: 201
Origin: http://example.com
Connection: keep-alive
Referer: http://example.com/test
Pragma: no-cache
Cache-Control: no-cache

-----------------------------349593416634898083182714306103
Content-Disposition: form-data; name="email"

foobar@gmail.com
-----------------------------349593416634898083182714306103--

@TarikAmine TarikAmine changed the title v0.27.1 FormData broken on v0.27.1 Apr 26, 2022
@pandaCure
Copy link

me to,axios@0.27.0 does't send formdata

@TarikAmine
Copy link
Author

TarikAmine commented Apr 26, 2022

axios@0.27.0 works, its 0.27.1 that fails

Edit: i'm using axios with cdn where this url https://unpkg.com/axios@0.27.0/dist/axios.min.js has this comment head

/* axios v0.27.0 | (c) 2022 by Matt Zabriskie */
/* axios v0.26.1 | (c) 2022 by Matt Zabriskie */

so i'm a bit confused

@TarikAmine TarikAmine changed the title FormData broken on v0.27.1 FormData broken sent as 'application/x-www-form-urlencoded' insteads of 'multipart/form-data' on v0.27.1 Apr 26, 2022
@TarikAmine TarikAmine changed the title FormData broken sent as 'application/x-www-form-urlencoded' insteads of 'multipart/form-data' on v0.27.1 FormData is sent as 'application/x-www-form-urlencoded' insteads of 'multipart/form-data' on v0.27.1 Apr 26, 2022
@TarikAmine TarikAmine changed the title FormData is sent as 'application/x-www-form-urlencoded' insteads of 'multipart/form-data' on v0.27.1 v0.27.1 FormData is sent as 'application/x-www-form-urlencoded' insteads of 'multipart/form-data' Apr 26, 2022
@romain-banchetti
Copy link

Same problem here, we downgraded to 0.27.0.

@TarikAmine TarikAmine changed the title v0.27.1 FormData is sent as 'application/x-www-form-urlencoded' insteads of 'multipart/form-data' v0.27.1 FormData is sent as 'application/x-www-form-urlencoded' instead of 'multipart/form-data' Apr 26, 2022
@jasonsaayman
Copy link
Member

I dont know why that is the case in unpackage but please use https://unpkg.com/axios@0.27.1/dist/axios.min.js

@TarikAmine
Copy link
Author

TarikAmine commented Apr 26, 2022

https://unpkg.com/axios@0.27.1/dist/axios.min.js is broken

the problem with unpackage is that they label 0.26.1 as 0.27.0, but the bug stands and 0.27.1 is broken with bad content type and missing boundry

@jasonsaayman
Copy link
Member

Linking #4631

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants