Enable CORS on Apache
September 7 201770 words, ~1 min. read
apache
Follow the steps below to enable CORS on Apache,
- Add a new configuration file, say
cors.conf, in apache configuration directory,/etc/httpd/conf.dwith the following contents,
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
Header set Access-Control-Allow-Methods "OPTIONS,POST,PUT,GET,DELETE"
Header set Access-Control-Allow-Headers "Content-Type, Version"
</IfModule>
Note: Ensure to provide appropriate hostname and headers for Access-Control-Allow-Origin and Access-Control-Allow-Headers values in the above configuration.
- Restart or reload
apache, to ensure changes are applied
apachectl -k graceful