@tina
To enable CORS in Apache2 and XAMPP, you can add the following code to your Apache configuration file:
- Open your Apache configuration file. This file is typically located at /etc/apache2/apache2.conf on Linux systems or in the conf folder of your XAMPP installation.
- Find the tag that corresponds to the directory you want to enable CORS for. This is typically the directory where your website files are located.
- Add the following lines inside the tag:
1
2
3
|
Header set Access-Control-Allow-Origin "*"
Header set Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept"
Header set Access-Control-Allow-Methods "GET, POST, OPTIONS"
|
- Save the changes to the configuration file and restart Apache to apply the changes. On Linux systems, you can do this by running the following command:
1
|
sudo systemctl restart apache2
|
Once you have enabled CORS in Apache2 or XAMPP, requests from other domains should now be able to access your resources.