Skip to content

Instantly share code, notes, and snippets.

@gabrielke
Forked from brianlmoon/apache_cors_example
Created March 20, 2018 14:45
Show Gist options
  • Select an option

  • Save gabrielke/740f7b9359b623c09f31d760f6938aeb to your computer and use it in GitHub Desktop.

Select an option

Save gabrielke/740f7b9359b623c09f31d760f6938aeb to your computer and use it in GitHub Desktop.
CORS example for Apache with multiple domains
# Sets CORS headers for request from example1.com and example2.com pages
# for both SSL and non-SSL
SetEnvIf Origin "^https?://[^/]*(example1|example2)\.com$" ORIGIN=$0
Header set Access-Control-Allow-Origin %{ORIGIN}e env=ORIGIN
Header set Access-Control-Allow-Credentials "true" env=ORIGIN
# Always set Vary: Origin when it's possible you may send CORS headers
Header merge Vary Origin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment