Skip to content

Instantly share code, notes, and snippets.

@r-brown
Last active June 17, 2019 04:27
Show Gist options
  • Save r-brown/bfb576d0dd4cf33d7d63 to your computer and use it in GitHub Desktop.
Save r-brown/bfb576d0dd4cf33d7d63 to your computer and use it in GitHub Desktop.
Apache HTTPD configuration - Enable CORS for NetLicensing API (RESTful)
<VirtualHost netlicensing.labs64.com:443>
...
<Location /core>
# CORS withCredentials=false (without cookies)
Header always set Access-Control-Allow-Origin "*"
Header always set Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS"
Header always set Access-Control-Allow-Headers "Content-Type, Accept, Authorization"
Header always set Access-Control-Max-Age: "3600"
RewriteEngine On
RewriteCond %{REQUEST_METHOD} OPTIONS
RewriteRule ^(.*)$ $1 [R=200,L,E=HTTP_ORIGIN:%{HTTP:ORIGIN}]]
# CORS withCredentials=true (with cookies)
SetEnvIfNoCase ORIGIN (.*) ORIGIN=$1
Header always set Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS"
Header always set Access-Control-Allow-Origin "%{ORIGIN}e"
Header always set Access-Control-Allow-Credentials "true"
Header always set Access-Control-Allow-Headers "Content-Type, Accept, Authorization"
Header always set Access-Control-Max-Age: "3600"
RewriteEngine On
RewriteCond %{REQUEST_METHOD} OPTIONS
RewriteRule ^(.*)$ $1 [R=200,L,E=HTTP_ORIGIN:%{HTTP:ORIGIN}]
</Location>
...
</VirtualHost>
@r-brown
Copy link
Author

r-brown commented May 16, 2015

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