Page 1 of 1

Fixing Cross-origin resource sharing (CORS) on nginx (add_header Access-Control-Allow-Origin)

Posted: Mon Mar 18, 2024 4:27 pm
by myVesta
How to fix the Cross-origin resource sharing (CORS) policy on myVesta on the nginx level

On SSH, logged in as root, do the following.

First, define your myVesta user and domain as a variable:

Code: Select all

USER='youruser'
DOMAIN='yourdomain.com'
Now you can copy-paste the following block:

Code: Select all

cd /home/$USER/conf/web
echo "add_header Access-Control-Allow-Origin '*';" > snginx.$DOMAIN.conf
ln -s snginx.$DOMAIN.conf nginx.$DOMAIN.conf
systemctl restart nginx