How to remove 'text/plain;charset=UTF-8' from content-type header?
See original GitHub issueHi, I am trying to send a post request to PostgREST to invoke a stored procedure:
const data = await $fetch('http://http-logger:3001/rpc/test_proc', {
method: 'post',
headers: {
Prefer: 'params=single-object',
Accept: 'application/json',
'Content-Type': 'application/json'
},
body: {some: 'json'}
})
Results in this request:
POST /rpc/test_proc HTTP/1.1
host: http-logger:3001
connection: keep-alive
prefer: params=single-object
accept: application/json
content-type: application/json, text/plain;charset=UTF-8
accept-language: *
sec-fetch-mode: cors
user-agent: undici
accept-encoding: gzip, deflate
content-length: 15
{"some":"json"}
I need to remove the ‘text/plain;charset=UTF-8’ part from the content-type. Is this possible? Should it even be there as I have explicitly defined the content-type header? Many thanks Ian
Issue Analytics
- State:
- Created a year ago
- Comments:6
Top Results From Across the Web
HttpClient: How to Remove Charset From Content-Type Header
Removing the Charset From a Content-Type Header. Solution is simple - we can create StringContent with whatever encoding and then set charset to ......
Read more >HttpClient: How to remove charset from ... - Gunnar Peipman
Removing charset from content-type header. Solution is simple – we can create StringContent with whatever encoding and then set charset to empty ...
Read more >HTTP request, content-type missing - Stack Overflow
But, when I remove the content-type, the server receives "text/plain;charset=UTF8". Why is my content-type header not being sent?
Read more >Managing Messages - Amazon Lex - AWS Documentation
When you use a message group to group messages by type, don't use the x-amz-lex:accept-content-types header. For more information about the x-amz-lex:accept- ...
Read more >How to remove header.Content-type? - Google Cloud Community
So my proxy endpoint asks for a json payload. And the user will call the proxy by supplying a json payload and of...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Actually, it is only an issue with undici fetch in ohmyfetch context, here’s a snippet to test it out :
globalThis.fetch:
ohmyfetch:
I tried on node 16 and I had no issue with node-fetch. So, it’s an issue with ohmyfetch’s implementation of undici fetching. It doesn’t happen with
unjs/node-fetch-native
alone. I also realized it doesn’t happen if you omit the body.I can confirm that this is only an issue with undici fetch (
globalThis.fetch
)