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.

Cannot override content-type?

See original GitHub issue

Doing this:

axios({
  method: 'post',
  url: '/some/url',
  data: { prop: value },
  headers: {
    'content-type': 'application/vnd.myapp.type+json'
  }
});

…causes a request with content-type set to application/json;charset=UTF-8 application/vnd.peregrine.activation+json.

Is there a correct way to override content-type, or is this just a bug?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:2
  • Comments:14 (1 by maintainers)

github_iconTop GitHub Comments

19reactions
AgoloAhmedElhadycommented, Nov 23, 2017

I am facing the same issue but only with GET Requests

const config = {
        headers: {
          'Content-Type': 'application/json',
          Authorization: `Bearer ${user.jwt}`,
        },
      };
axios.get(url, config)

EDIT : According to #86 I added empty data object and luckily it worked.

const config = {
        headers: {
          'Content-Type': 'application/json',
          Authorization: `Bearer ${user.jwt}`,
        },
        data: {},
      };
axios.get(url, config)
17reactions
daktwigimcommented, Sep 20, 2017

it still doesn’t work… why did it closed?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't override content-type PHP server headers - Stack Overflow
Show activity on this post. I can set other headers with ease, but as SOON as I try to set a header with...
Read more >
I am unable to overwrite the Content-Type - Just getting started
My question: I try to overwrite the automatically generated content-type by application/json but I am not able to fix that.
Read more >
Impossible to override Content-Type header? - Google Groups
override the Content-Type header if it already exists. ... I think the problem is that you can't modify the header once it's already...
Read more >
How to add Content-Type for income request by conditions ...
I have a scenario that adding 'application/json' as default Content-Type for incoming request if cannot find Content-Type from request in MPGW, ...
Read more >
Can't change content-type in REST response
Can't change content-type in REST response ⏩ Post By ✓ James Westley-Farrell ✓ Intersystems Developer Community CSP ▶️ REST API ...
Read more >

github_iconTop Related Medium Post

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