How to enable cross origin in apache.
Step 1: To enable cross origin in apache2 you need enable mod_headers. To ensure that
it's enabled by run below command in terminal.
a2enmod headers
Step 2: Next add the following line inside the sections of your server config
(usually located in a *.conf file, such as httpd.conf or apache.conf), or within a .htaccess file.
Go to /etc/apache2
Then copy paste the below line:
sudo gedit apache2.conf
Add below lines:
<IfModule mod_headers.c>
Header always set Access-Control-Allow-Origin "*"
Header always set Access-Control-Allow-Methods "POST, GET, OPTIONS, PUT, DELETE"
Header always set Access-Control-Allow-Headers "access-control-allow-origin, authorization,content-Type,x-requested-with,accept,origin,access-control-request-method,access-control-request-headers"
</IfModule>
Finally save the apache2.conf file and reload the apache service running below code:
sudo service apache2 reload
Enjoy..
Comments
Post a Comment