Skip to content

Commit

Permalink
example on how to serve CORS headers in php
Browse files Browse the repository at this point in the history
  • Loading branch information
dschwen committed Mar 12, 2013
1 parent 69bd647 commit a232a7f
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions cors_php.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: POST, GET, OPTIONS');
header('Access-Control-Max-Age: 1000');
if(array_key_exists('HTTP_ACCESS_CONTROL_REQUEST_HEADERS', $_SERVER)) {
header('Access-Control-Allow-Headers: '
. $_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']);
} else {
header('Access-Control-Allow-Headers: *');
}

if("OPTIONS" == $_SERVER['REQUEST_METHOD']) {
exit(0);
}



0 comments on commit a232a7f

Please sign in to comment.