Skip to content

Instantly share code, notes, and snippets.

@scodx
Last active May 8, 2019 21:36
Show Gist options
  • Save scodx/43e1cd75a8abe113c902b165f1308708 to your computer and use it in GitHub Desktop.
Save scodx/43e1cd75a8abe113c902b165f1308708 to your computer and use it in GitHub Desktop.
Enable cross origin requests

You can control this via HTTP header by adding Access-Control-Allow-Origin. Setting it to * will accept cross-domain AJAX requests from any domain.

Using PHP it's really simple, just add the following line into the script that you want to have access outside from your domain:

header("Access-Control-Allow-Origin: *");

or whatever methods you have available in libraries like Guzzle or Http Foundation to manage HTTP requests

Don't forget to enable mod_headers module in httpd.conf.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment