Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Created by PhpStorm.
- * User: mertcan
- * Date: 28.11.2015
- * Time: 22:38
- */
- // allowed origins
- $allowedOrigins = array(
- '(http(s)://)?(www\.)?my\-domain\.com',
- '(http(s)://)?(www\.)?my\-domain\.com',
- '(http(s)://)?(www\.)?my\-domain\.com'
- );
- if (isset($_SERVER['HTTP_ORIGIN']) && $_SERVER['HTTP_ORIGIN'] != '') {
- foreach ($allowedOrigins as $allowedOrigin) {
- if (preg_match('#' . $allowedOrigin . '#', $_SERVER['HTTP_ORIGIN'])) {
- header('Access-Control-Allow-Origin: ' . $_SERVER['HTTP_ORIGIN']);
- header('Access-Control-Allow-Methods: GET, PUT, POST, OPTIONS, DELETE');
- header('Access-Control-Max-Age: 1728000');
- header('Access-Control-Allow-Headers: Content-Type, Authorization, X-Requested-With');
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement