Question

CORS apache linux Access-Control-Allow-Origin "*"

Posted May 16, 2015 45.4k views
ApacheDigitalOceanConfiguration Management

Can´t make Access-Control-Allow-Origin “” working, I have done the setup for making .htaccess working right, I know it´s working right because ErrorDocument 404 is working perfect, but: Header set Access-Control-Allow-Origin “” is not. I have added Header set Access-Control-Allow-Origin “*” inside etc/apache2/sites-available/000-default.conf but nothing, can you help me with this? thanks, I have read all the related support about this, tried everything but nothing.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
3 answers

The mod_headers module could be disabled. Try enabling it and reload Apache.

sudo a2enmod headers
sudo service apache2 reload

If you still don’t see the header try adding it to your .htaccess file:

Header set Access-Control-Allow-Origin "*"
  • This is not working.... any solution ?

  • Still Not working.
    I have set this header:
    Header set Access-Control-Allow-Origin “*”

    in /etc/apache2/apache2.conf in <Directory> section, as well as in .htaccess file in /var/www/html.

    My server is able to ping other servers which give me response header as ‘Header set Access-Control-Allow-Origin “*” ’. Then, why is my server not able to do so?

Thanks. It works!
Setting this header -

Header always set Access-Control-Allow-Origin "*"

in apache.config file and then enabling the mod_headers module and restarting the apache2 using -

sudo a2enmod headers
sudo service apache2 reload

worked for me.

Submit an Answer