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

Post Reply
User avatar
myVesta
Site Admin
Posts: 964
Joined: Fri Jun 19, 2020 9:59 am
Has thanked: 10 times
Been thanked: 6 times

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
Post Reply