I want to activate Cross-Origin Resource Sharing (CORS) on a Bitnami WordPress website in Amazon Lightsail.
Resolution
To activate CORS on a Bitnami WordPress website in Lightsail, complete the following steps:
-
Open the vhosts.conf file:
sudo vi /opt/bitnami/apache/conf/vhosts/wordpress-vhost.conf
-
Press i.
-
Add the following lines the directory:
...
<Directory /opt/bitnami/wordpress>
...
Header set Access-Control-Allow-Origin "*"
...
</Directory>
-
Press Esc, and then enter :wq! to save the file.
-
Restart Apache:
sudo /opt/bitnami/ctlscript.sh restart apache
Verify that CORS is active
Run the following command:
Note: Replace example-URL with your domain's URL.
curl -I <example-url>
If the output includes Access-Control-Allow-Origin: *, then CORS is active.