0

I got such an error.

Blocked request to a resource of another origin: "Same Origin Policy" does not allow to load remote resources from https://test-domain.com/public/fetch_data.php/ (missing CORS header "Access-Control-Allow-Origin" ).

I added code at the begining to my config file https://test-domain.com/private/initialize.php

$accepted_origins = array("https://test-domain.com");

if(isset($_SERVER['HTTP_ORIGIN'])){
    if(in_array($_SERVER['HTTP_ORIGIN'], $accepted_origins)){
        header('Access-Control-Allow-Origin: ' . $_SERVER['HTTP_ORIGIN']);
    }else{
        header("HTTP/1.1 403 Origin Denied");
        return;
    }
}

My question: Is it enough or is there anything else to add?

1 Answers1

0

solution

How to send a cross domain ajax request

header('Access-Control-Allow-Origin: *');