-
-
Save yommu/a60f35098a6c77e8f45ac18eb13bf047 to your computer and use it in GitHub Desktop.
Apache directive for a CORS to be used in a vhost or htaccess
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<IfModule mod_headers.c> | |
# Enter possible domains and a cathcall regex for the subdomain. | |
SetEnvIf Origin "^http(s)?://(.+\.)?(domain1\.com|domain2\.com|domain3\.com)$" AllowOrigin=$0 | |
Header always set Access-Control-Allow-Origin "%{AllowOrigin}e" env=AllowOrigin | |
Header merge Vary "Origin" | |
Header always append Access-Control-Max-Age "1000" | |
Header always append Access-Control-Allow-Headers "X-Requested-With, Content-Type, Origin, Authorization, Accept, Accept-Encoding, \ | |
if-modified-since, pragma, cache-control" | |
Header always set Access-Control-Allow-Methods "POST, GET, OPTIONS, DELETE, PUT" | |
# Preflight: Add a rewrite to respond with a 200 SUCCESS on every OPTIONS request. | |
RewriteEngine On | |
RewriteCond %{REQUEST_METHOD} OPTIONS | |
RewriteRule ^(.*)$ $1 [R=200,L] | |
</IfModule> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment