Tag: cors

  • Enable CORS in Nginx

    To enable CORS in nginx, add the following inside web sites server config.

    add_header 'Access-Control-Allow-Origin' '*';
    add_header 'Access-Control-Allow-Credentials' 'true';
    add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
    add_header 'Access-Control-Allow-Headers' 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';

    Restart nginx

    systemctl restart nginx

    See CORS

  • Enable CORS in Apache

    To enable CORS in apache, add the following in VirtualHost or .htaccess

    Header always set Access-Control-Allow-Origin "*"
    Header always set Access-Control-Allow-Methods "POST, GET, OPTIONS"
    

    If your apache installation don’t have mod_headers installed, you need it enabled with

    a2enmod headers
    systemctl restart apache2