₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,325,481 members, 8,422,268 topics. Date: Monday, 08 June 2026 at 01:19 AM

Toggle theme

Why Is The Browser Messing With My Headers - Programming - Nairaland

Nairaland ForumScience/TechnologyProgrammingWhy Is The Browser Messing With My Headers (790 Views)

1 Reply (Go Down)

Why Is The Browser Messing With My Headers by chukwuebuka65(op): 10:01pm On Aug 19, 2023
I have an endpoint that receives “content-type” of “application/json” but when I hit it from javascript, it returns a 415 unsupported media type status code. But When I use postman it works. So I inspected the network tab of dev tools and discovered the request headers content type is text/plain instead of the application/json I set it to be. Why is this happening ?
Re: Why Is The Browser Messing With My Headers by Paystack(f): 10:47pm On Aug 19, 2023
chukwuebuka65:
I have an endpoint that receives “content-type” of “application/json” but when I hit it from javascript, it returns a 415 unsupported media type status code. But When I use postman it works. So I inspected the network tab of dev tools and discovered the request headers content type is text/plain instead of the application/json I set it to be. Why is this happening ?
This is why ChatGpt was created
Re: Why Is The Browser Messing With My Headers by chukwuebuka65(op): 11:14pm On Aug 19, 2023
Paystack:
This is why ChatGpt was created
In as much as chatgpt is useful, its still not a human being. I actually got the answer i am looking for on stackoverflow as chatgpt couldnt help me.
Re: Why Is The Browser Messing With My Headers by Paystack(f): 11:42pm On Aug 19, 2023
chukwuebuka65:
In as much as chatgpt is useful, its still not a human being. I actually got the answer i am looking for on stackoverflow as chatgpt couldnt help me.
It provides better help and faster help than humans as at now.
Re: Why Is The Browser Messing With My Headers by Davidcorny: 2:23am On Aug 20, 2023
chukwuebuka65:
I have an endpoint that receives “content-type” of “application/json” but when I hit it from javascript, it returns a 415 unsupported media type status code. But When I use postman it works. So I inspected the network tab of dev tools and discovered the request headers content type is text/plain instead of the application/json I set it to be. Why is this happening ?
Your path to the file is wrong. Target your files properly.
Re: Why Is The Browser Messing With My Headers by stanliwise(m): 10:25am On Aug 20, 2023
chukwuebuka65:
I have an endpoint that receives “content-type” of “application/json” but when I hit it from javascript, it returns a 415 unsupported media type status code. But When I use postman it works. So I inspected the network tab of dev tools and discovered the request headers content type is text/plain instead of the application/json I set it to be. Why is this happening ?
Set the content-type in JS. It’s most likely never the browser
Re: Why Is The Browser Messing With My Headers by Luckydonalds(m): 4:03pm On Aug 20, 2023
stanliwise:
Set the content-type in JS. It’s most likely never the browser
OP, this is the answer you are lookin for here. Set the content type in your headers before sending the request
Re: Why Is The Browser Messing With My Headers by chukwuebuka65(op): 6:39pm On Aug 20, 2023
Luckydonalds:
OP, this is the answer you are lookin for here. Set the content type in your headers before sending the request
I have found the solution.
Re: Why Is The Browser Messing With My Headers by chukwuebuka65(op): 6:40pm On Aug 20, 2023
stanliwise:
Set the content-type in JS. It’s most likely never the browser
I have found the solution.
Re: Why Is The Browser Messing With My Headers by stanliwise(m): 6:43pm On Aug 20, 2023
chukwuebuka65:
I have found the solution.
You can as well talk about the solution just so someone stumble on this thread in future
Re: Why Is The Browser Messing With My Headers by Paystack(f): 8:39pm On Aug 20, 2023
stanliwise:
You can as well talk about the solution just so someone stumble on this thread in future
You're wise
Re: Why Is The Browser Messing With My Headers by chukwuebuka65(op): 9:47pm On Aug 20, 2023
stanliwise:
You can as well talk about the solution just so someone stumble on this thread in future
It has to do with cors. I was getting cors error, so I added “no cors” to the fetch mode configuration to bypass the error . But with that configuration, the browser does not allow any other value for the “content-type” header expect “text/plain”. So I contacted the backend team and we were able to rectify it.
1 Reply

How AI Agents Are Moving From The Browser To The Physical World.Google Chrome Or Apple Safari? Which Browser Is BetterPlease Help My Android Studio Is Messing Up234

Java Spring Boot Needed UrgentlyEmbarking On A Blockchain Development Journey: A Learner's DiaryMedical Engineering