segmentio / analytics-node

The hassle-free way to integrate analytics into any node application.

Home Page:https://segment.com/libraries/node

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

content-type not being set as per docs to "application/json"

mattrlong opened this issue · comments

According to the Segment api documentation the content-type should be set to 'application/json' however while using this library the content-type header is coming through as text/plain.

@mattrlong Hello! On request headers or response headers?

If on request: axios uses Content-Type': 'application/x-www-form-urlencoded by default.

If on response headers, then it's the server you're making requests to that's returning text/plain as it's content-type.

Hi @pbassut apologies, I was referring to the request headers of the requests made to segment's API using this library. As per the docs referenced above this should be set (overriding Axios' default) to application/json.

I have spotted this issue, as our project is using analytics-node to integrate with Segment, and our automated test tool is noticing the text/plain header and forcing us to parse the text to JSON. If the header were set correctly we'd immediately be able to interrogate the JSON to confirm we've set the properties correctly.

But Axios set it's default content-type to application/json. That is, if we don't set anything. And we don't.
Are you sure something else in your chain isn't making that header text/plain?

Let me put this another way, can you help me spot where in the code we mention any content-type whatsoever?
Thanks! And sorry I took long to answer this.