Skip to content

Instantly share code, notes, and snippets.

@notslang
Last active December 29, 2015 12:19
Show Gist options
  • Save notslang/7670196 to your computer and use it in GitHub Desktop.
Save notslang/7670196 to your computer and use it in GitHub Desktop.
add this to the top of the main contact form 7 file to fix its lack of CORS
if (isset($_SERVER['HTTP_ORIGIN']) && in_array($_SERVER['HTTP_ORIGIN'], array('http://chazsouthard.com', 'http://localhost:1111'))) {
header("Access-Control-Allow-Origin: {$_SERVER['HTTP_ORIGIN']}");
header('Access-Control-Allow-Credentials: true');
header('Access-Control-Max-Age: 86400'); // cache for 1 day
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment