Why Is The Browser Messing With My Headers - Programming - Nairaland
Nairaland Forum › Science/Technology › Programming › Why Is The Browser Messing With My Headers (790 Views)
| 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: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: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: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: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: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: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:I have found the solution. |
| Re: Why Is The Browser Messing With My Headers by chukwuebuka65(op): 6:40pm On Aug 20, 2023 |
stanliwise:I have found the solution. |
| Re: Why Is The Browser Messing With My Headers by stanliwise(m): 6:43pm On Aug 20, 2023 |
chukwuebuka65: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're wise |
| Re: Why Is The Browser Messing With My Headers by chukwuebuka65(op): 9:47pm On Aug 20, 2023 |
stanliwise: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. |
How AI Agents Are Moving From The Browser To The Physical World. • Google Chrome Or Apple Safari? Which Browser Is Better • Please Help My Android Studio Is Messing Up • 2 • 3 • 4
Java Spring Boot Needed Urgently • Embarking On A Blockchain Development Journey: A Learner's Diary • Medical Engineering