Skip to content

Instantly share code, notes, and snippets.

@NosearY
Created February 26, 2022 06:06
Show Gist options
  • Save NosearY/59976f29f932b1224b6eada0f0684171 to your computer and use it in GitHub Desktop.
Save NosearY/59976f29f932b1224b6eada0f0684171 to your computer and use it in GitHub Desktop.
Allow CORS in Apache Web Server
<VirtualHost *:80>
DocumentRoot /var/www/html/
ServerName example.com
Header always set Strict-Transport-Security "max-age=63072000; includeSubDomains"
SetEnvIf Origin "http(s)?://(www\.)?(dev.test.co:18088|uat.test.co:18088|test.com)$" AccessControlAllowOrigin=$0
Header always set Access-Control-Allow-Origin %{AccessControlAllowOrigin}e env=AccessControlAllowOrigin
Header always set Access-Control-Allow-Methods "PUT, GET, POST, DELETE, OPTIONS"
Header always set Access-Control-Allow-Headers "x-requested-with, Content-Type, origin, authorization, accept, client-security-token, token, x-locale"
Header always set Access-Control-Expose-Headers "Content-Security-Policy, Location"
Header always set Access-Control-Max-Age "600"
RewriteEngine On
RewriteCond %{REQUEST_METHOD} OPTIONS
RewriteRule ^(.*)$ $1 [R=200,L]
</VirtualHost>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment