question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Content-Type header not set

See original GitHub issue

Describe the bug

setting the header ‘Content-Type’ seem to be ignored.

To Reproduce

let data = new FormData();
//... appending values to formdata and then
axios
    .request({
      url: '/member/tasks/addCommentApi.json',
      method: 'POST',
      data: data,
      headers: {
        'Content-Type': 'multipart/form-data',
        'X-Test': 'dan',
      },
    })

Expected behavior

headers should contain Content-Type, they don’t but X-Test header is present.

Environment

  • Axios Version [ 0.20.0-0]
  • ReactNative [0.62.1]

Additional context/Screenshots

Add any other context about the problem here. If applicable, add screenshots to help explain.

nothing else to add

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7

github_iconTop GitHub Comments

3reactions
danielzzzcommented, Aug 25, 2020

thanks @rafamarts , I think it’s still NOT working on react-native.

0reactions
gunaygultekincommented, May 3, 2021

I have the same issue. I solved by adding data: {}

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why do we need to set the Content-Type header of an HTTP ...
Content-Type in the header of a HTTP request specifies to the server what data it should expect. If a server allows and accepts...
Read more >
Content-Type - HTTP - MDN Web Docs - Mozilla
The Content-Type representation header is used to indicate the original media type of the resource (prior to any content encoding applied ...
Read more >
Setting 'Content-Type' header does not work. #2544 - GitHub
It seems like setting Content-Type header is impossible without data property: const api = Axios.create({ baseURL: 'https://my-url', ...
Read more >
Missing Content-Type Header Detected on Web Application
A Missing Content-Type Header is an attack that is similar to a Out of Band Code Evaluation (RoR) that -level severity. Categorized as...
Read more >
Content type is not specified - PortSwigger
If a response does not specify a content type, then the browser will usually analyze the response and attempt to determine the MIME...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found