Enable CORS with wamp on windows 8

I have a cross domain problem with the application I am doing. I really spent hours finding a solution on how to enable CORS using wamp (localhost), but nothing worked for me.

I have Apache 2.4.9 on Windows 8.1. I turned on the headers, I tried to put

Header add Access-Control-Allow-Origin "*" Header add Access-Control-Allow-Methods: "GET,POST,OPTIONS,DELETE,PUT" 

in .htaccess and in http.conf, as well as many other options.

If someone had a solution, that would be great!

+6
source share
2 answers

You must also activate the Apache header module.

Using the wampmanager menu does the following: -

 wampmanager -> Apache -> Apache modules -> headers_module 

Make sure this is checked, if not, click this menu item and wait a few seconds for WampServer to restart Apache.

+9
source

I had the same problem and solved it with these three steps:

1) in the Apache configuration file (for me the path was C: \ wamp \ bin \ apache \ apache2.4.18 \ conf \ httpd.conf) add the line: Header set Access-Control-Allow-Origin "*" in the contents of the <Directory> tag <Directory> :

 DocumentRoot "c:/wamp/www" <Directory "c:/wamp/www/"> Options +Indexes +FollowSymLinks Header set Access-Control-Allow-Origin "*" AllowOverride all Require local </Directory> 

2) activate "headers_module" in apache modules (it will also restart your Apache server, effectively applying the changes made in step 1)

3) clear the browser cache (I use chrome, and I was told that the best way to β€œhard clean” the cache was to go into the developer tools β†’ the β€œNetworks” tab β†’ right-click β†’ clear the browser cache) (by the way, cleaning the browser cache often useful for debugging in chrome)

Now that should work. Good luck

+9
source

Source: https://habr.com/ru/post/978505/


All Articles