apache2 header set access-control-allow-origin * code example
Example 1: apache2 CORS
##### WORKING ON APACHE2 Unix CONFIGURATION #####
# To learn more about CORS : #
# https://fr.wikipedia.org/wiki/Cross-origin_resource_sharing #
# First you need to enable headers_module in your global Apache2 #
# httpd.conf configuration file. To do so, uncomment the line #
LoadModule headers_module modules/mod_headers.so
# Once it's done, you need to parameter the following statements #
# in your dedicated <Directory> , <Location> , <Files> #
# or <VirtualHost> .conf file, or inside your project within #
# .htaccess file #
Header set Access-Control-Allow-Origin "*"
Header set Access-Control-Allow-Methods "HEAD, GET, POST, PUT, PATCH, DELETE"
Header set Access-Control-Allow-Headers "Origin, Content-Type, X-Auth-Token"
# Finally restart your apache server. #
# You are free to manipulate other statements, referenced #
# into the wiki. #
# This has for effect to manipulate default HTTP Headers sent by #
# your server, in order to communicate with a remote client #
# browser. #
Example 2: apachi configure allow cors in the file directory
Enable CORS in Apache - "C:\xampp\apache\conf\extra -> in httpd-vhosts inside file add this line to access"
Header set Access-Control-Allow-Origin "*"