403 forbidden error in post request with data, works fine when directly loaded in browser

Viewed 23

i have this simple php code which throws error 403 forbidden when we send post request through xhr to this page but works fine when directly called in broswer. i assumed that there might by CORS issue or any other issue so tried to accept those things by adding headers in php. its apache + nginx server

<?php
ini_set('display_errors', 'On');
error_reporting(E_ALL);
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST');
header("Access-Control-Allow-Headers: X-Requested-With");
echo 'test msg';
?>

when called direclty it gives result. here is link

https://jsfiddle.xyz/api/v1/widgets/update.php?/66456

the post request is being made from same domain

0 Answers
Related