How do I activate CORS on a Bitnami WordPress website in Lightsail?

Lecture de 1 minute(s)
0

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:

  1. Open the vhosts.conf file:

    sudo vi /opt/bitnami/apache/conf/vhosts/wordpress-vhost.conf
  2. Press i.

  3. Add the following lines the directory:

    ...
    <Directory /opt/bitnami/wordpress>
    ...
    Header set Access-Control-Allow-Origin "*"
    ...
    </Directory>
  4. Press Esc, and then enter :wq! to save the file.

  5. 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.

AWS OFFICIEL
AWS OFFICIELA mis à jour il y a 2 mois