Skip to content

Instantly share code, notes, and snippets.

@easychen
Created June 20, 2017 08:34
Show Gist options
  • Save easychen/0e420ef253e971483a7b0ef50440ee4d to your computer and use it in GitHub Desktop.
Save easychen/0e420ef253e971483a7b0ef50440ee4d to your computer and use it in GitHub Desktop.
让PHP build-in web server支持跨域: php -S locahost:4000 route.php
<?php
if (file_exists($_SERVER["SCRIPT_FILENAME"]))
{
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Headers: origin,x-requested-with,content-type');
header('Access-Control-Allow-Methods: PUT,GET,POST,DELETE,OPTIONS');
readfile($_SERVER["SCRIPT_FILENAME"]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment