Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php cors multiple headers

// enter the origins you want allowed for cors to work
$_SESSION['allowed_origins'] = array('*', "site1.com", "site2.com");

// use this function to cycle through the list and enter these dynamically
function setAllowedHeadersAPI($array) {
    foreach ($_SESSION['allowed_origins'] as $origin) {
        header("Access-Control-Allow-Origin: $origin");
        header("Access-Control-Allow-Headers: $origin");
    }
}

// call function and pass the array through it
setAllowedHeadersAPI($_SESSION['allowed_origins']);
Comment

PREVIOUS NEXT
Code Example
Php :: laravel password validation 
Php :: convert to int php 
Php :: call to a member function connection() on null test laravel 
Php :: error repoerting in php 
Php :: password strength php 
Php :: disable quantity field in woocommerce 
Php :: read-json-data-response-using-php 
Php :: Array Contant PHP 
Php :: how refresh object in database in laravel 
Php :: get array key php 
Php :: wordpress remove add new button 
Php :: php replace every occurrence of character in string 
Php :: get first day of current month php 
Php :: php 7.4 modules list 
Php :: message mkdir() invalid path filename drivers/session_files_driver.php 
Php :: php slugify 
Php :: php sum array of objects 
Php :: save array in mysql php 
Php :: php.ini path 
Php :: Class "AppUser" not found 
Php :: get taxonomies for custom post type 
Php :: how to add recaptcha validation in php 
Php :: where not null in laravel 
Php :: php date start of day 
Php :: Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://vtl-lab.com/VN/crecc-cms/api/member/register.json. (Reason: CORS request did not succeed). 
Php :: get url with php 
Php :: gmdate in php 
Php :: web scraping php 
Php :: PHP Create a MySQL Database 
Php :: csrf token mismatch laravel api 
ADD CONTENT
Topic
Content
Source link
Name
2+3 =