1

I set a header for post a request with application/x-www-form-urlencoded form body; here's my code

var headers = new Headers();
      headers.append('Content-Type','application/x-www-form-urlencoded');

      fetch(url, {
        method: "POST",
        mode:"cors",
        header:headers,
       body: qs.stringify(params)
    })

But Content-type changed autoly in the request

Content-Type    text/plain;charset=UTF-8

So that I can't receive this request params correctly. Any one meet that?

Lyle
  • 125
  • 2
  • 13

1 Answers1

2

CORS only allows a subset of content types. I lost lots of hours to this one. :)

See this answer. Even though application/x-www-form-urlencoded could be possible in a CORS request, I think it's very likely that your header is being overwritten by setting mode: 'cors' in your fetch call.

olieidel
  • 1,505
  • 10
  • 10
  • yeah.I'm surely lost lots of hour to this.And Cherniv is Right .And I love you too,man! – Lyle Sep 18 '17 at 12:24