Closed ghost closed 4 years ago
Tried an other node php library and the issue isn't there.
Thank you for reporting a problem. Please provide a working example.
I'm putting some form data in a json object and sending it to the server.
return fetch( process.env.VUE_APP_BACKEND_BASEURL + "/RestController.php?page_key=create", { method: "POST", body: JSON.stringify(wish), headers: { Accept: "application/json" } } ).then(response => response.json());
Then in the backend.
$_POST = json_decode(file_get_contents('php://input'), true);
OK I think I see the problem. The structure of SPHP is that the worker is spawned preemptively. In order to do that php://input is used to stall, transfer server environment and the request, before your script is executed. Therefore the stream is empty, when your script runs.
In short: I'm sorry. to say, that you can not use php://input that way with SPHP.
What you could do with SPHP is to store the JSON in a POST.
Oke well thanks for the time. I fixed it by running an Apache server and a node reverse proxy.
Hi,
I'm posting JSON data to my PHP backend. But I'm unable to get the data because php://input remains empty. Tried the same post on a appache server and everything seams to work fine. Am i missing a php lib? Or is this a know bug.