How to allow Access-Control-Allow-Origin: * for all the apis

Hi can i have some example configuration i’m scratching my head and not able to do it

till now i have installed nginex and made this configuration

server {
    listen 80;
    server_name  localhost;
    access_log off;
    location / {

            add_header 'Access-Control-Allow-Origin' "";
            add_header 'Access-Control-Allow-Credentials' 'true' always;
            add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS' always;
            add_header 'Access-Control-Allow-Headers' 'Accept,Authorization,Cache-Control,Content-Type,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Requested-With' always;

             add_header 'Content-Type' 'text/plain charset=UTF-8';
               proxy_pass http://grafana.staged-by-discourse.com;
            proxy_set_header    Host            $host;
            proxy_set_header    X-Real-IP       $remote_addr;
            proxy_set_header    X-Forwarded-for $remote_addr;
            port_in_redirect off;
            proxy_redirect  off;
            proxy_connect_timeout 300;

}

}

but still i’m getting same error please help

1 Like