Skip to content
Advertisement

Tag: http

Empty body in fetch POST request

I’m struggling with the fetch API in Javascript. When I try to POST something to my server with fetch method, the request body contains an empty array. But when I use Postman it works. Here is my server-side code in Node.js: Here is my client-side code: The problem is that the req.body is empty on server side. Answer The issue

JS Fetching batch data with HTTP

My RESTful service allows batching requests. I’m trying to combine requests into one batch with help of Fetch API: However it returns an error – bad request. I suppose I may combine HTTP requests in wrong way. Is there simpler way of doing this? Where in Network Chrome Dev Tools can I see nested HTTP requests? Answer Your code does

Refused to load the script because it violates the following Content Security Policy directive

When I tried to deploy my app onto devices with Android system above 5.0.0 (Lollipop), I kept getting these kind of error messages: 07-03 18:39:21.621: D/SystemWebChromeClient(9132): file:///android_asset/www/index.html: Line 0 : Refused to load the script ‘http://xxxxx’ because it violates the following Content Security Policy directive: “script-src ‘self’ ‘unsafe-eval’ ‘unsafe-inline'”. 07-03 18:39:21.621: I/chromium(9132): [INFO:CONSOLE(0)] “Refused to load the script ‘http://xxx’ because

What’s to stop malicious code from spoofing the “Origin” header to exploit CORS?

The way I understand it, if a client-side script running on a page from foo.com wants to request data from bar.com, in the request it must specify the header Origin: http://foo.com, and bar must respond with Access-Control-Allow-Origin: http://foo.com. What is there to stop malicious code from the site roh.com from simply spoofing the header Origin: http://foo.com to request pages from

HTTP Content-Type Header and JSON

I have always been trying to avoid using most of the HTTP protocol’s properties for the sake of fear of the unknown. However, I said to myself that I’m going to face fear today and start using headers purposefully. I have been trying to send json data to the browser and use it right away. For example, if I have

Advertisement