Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

php has been blocked by CORS policy

public function __construct()
            {
                parent::__construct();
                $this->load->model('api_model');
                $this->load->library('form_validation');
        
                Header('Access-Control-Allow-Origin: *'); //for allow any domain, insecure
                Header('Access-Control-Allow-Headers: *'); //for allow any headers, insecure
                Header('Access-Control-Allow-Methods: GET, POST, OPTIONS, PUT, DELETE'); //method allowed

//Or

        header('Access-Control-Allow-Origin: website_url');
        header("Content-Type: application/json; charset=UTF-8");
        Header('Access-Control-Allow-Methods: GET, POST, OPTIONS, PUT, DELETE'); //method allowed
            }
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #php #blocked #CORS #policy
ADD COMMENT
Topic
Name
5+2 =