How to Enable CORS for Apache httpd server? (Step-By-Step Process)

前端 未结 2 1635
-上瘾入骨i
-上瘾入骨i 2020-12-19 11:05

I was wondering if anybody can help me set up CORS on my Apache web server. I would appreciate a step-by-step process because many sites online are

相关标签:
2条回答
  • 2020-12-19 11:26
    # edit your conf/httpd.conf file.  Verify that the headers module is loaded
    LoadModule headers_module modules/mod_headers.so
    
    # to whitelist every origin, use
    Header set Access-Control-Allow-Origin "*"
    

    More info: http://enable-cors.org/server_apache.html

    0 讨论(0)
  • 2020-12-19 11:29

    The above answer is correct and put Inside the httpd.conf. This should be changed to whatever you set Document Root.

    On Ubuntu, httpd.conf is located in the directory /etc/apache2. apache2.conf is also located in /etc/apache2.

    On CENTOS 6 httpd.conf in the path /etc/httpd/conf/httpd.

    <Directory "/var/www/html">
            Header set Access-Control-Allow-Origin "*"
    </Directory>
    
    0 讨论(0)
提交回复
热议问题