All HowTo's Web Servers

Solution to CORS with Apache

This is how to resolve the CORS issue on an Apache server. The short of it is that a web page may require the browser to make Jquery calls to another server which rightfully rings alarm bells.

Add the following to the Apache vhost on the target server – where the Jquery is calling.

Header always set Access-Control-Allow-Origin "*"
Header always set Access-Control-Allow-Methods "POST, GET, OPTIONS, DELETE, PUT"
Header always set Access-Control-Max-Age "1000"
Header always set Access-Control-Allow-Headers "x-requested-with, Content-Type, origin, authorization, accept, client-security-token"
RewriteEngine On
RewriteRule ^(.*)$ $1 [R=200,L]


Leave a Reply

Your email address will not be published. Required fields are marked *