Hello,
I am dealing with a HTML5 app that is supposed to send me some data via a POST. My problem is that I never got the data from the HttpClient.
So, I have seen that before sending something, that app is sending the "OPTIONS" in the Method (instead of the POST, perhaps the reason I can not get the data or the content type). Following MDN, I tried to send "Access-Control-Allow-Methods: POST, GET, OPTIONS" like this (from a Filter)
But I am turning around (I don't understand what to do). Please do we have any example about ?
Thanks
EDIT : I saw in the PHP code provided they reply. Do I understand correctly that I should resend the headers received from the req ? I don't see any
I am dealing with a HTML5 app that is supposed to send me some data via a POST. My problem is that I never got the data from the HttpClient.
So, I have seen that before sending something, that app is sending the "OPTIONS" in the Method (instead of the POST, perhaps the reason I can not get the data or the content type). Following MDN, I tried to send "Access-Control-Allow-Methods: POST, GET, OPTIONS" like this (from a Filter)
B4X:
If req.Method="OPTIONS" Then
resp.Write("").SetHeader("Access-Control-Allow-Methods","POST, GET, OPTIONS")
End If
But I am turning around (I don't understand what to do). Please do we have any example about ?
Thanks
EDIT : I saw in the PHP code provided they reply. Do I understand correctly that I should resend the headers received from the req ? I don't see any
B4X:
// Access-Control headers are received during OPTIONS requests
if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_METHOD']))
header("Access-Control-Allow-Methods: GET, POST, OPTIONS");
if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']))
header("Access-Control-Allow-Headers: {$_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']}");
exit;
}
Last edited: