I have a website called "example.com". I have a PHP file on example.com that I make .ajax() requests to. I want to prevent other sites from making requests to this file. I'm setting Access-Control-Allow-Origin in this PHP file to do so. Here is my code
<?php
    header('Access-Control-Allow-Origin: https://example.com', false);
    if(isset($_POST["request"]){
        echo "Request Successful";
    }
?>
Can this approach be exploited? Is setting this header preventing other sites from making ajax requests to the PHP file? Thanks in advance for your help.
 
    