Dealing with CORS error

Hi,

I want to transform my plugin, I’m getting rid of my Python’s Flask server.
I’ve read A LOT about CORS errors, I know that I can use a proxy or use a node server BUT I want my plugin to be fully independent.

I tried to modify grafana.ini byt there is nothing about CORS, can someone help me ?

Nicolas

Hi, I encountered the same issue throughout the entire day. I tried various solutions, including attempting to run a simple API call locally through PHP (which failed due to a CA certificate issue) and installing multiple new extensions. However, the solution turned out to be quite simple: I set up a reverse proxy in Nginx for my external API, like this:

server {
listen 443;
ssl on;
ssl_certificate /etc/ssl/certificate.crt;
ssl_certificate_key /etc/ssl/certificate.key;
server_name domainOfYourGrafana;
access_log /var/log/nginx/nginx.vhost.access.log;
error_log /var/log/nginx/nginx.vhost.error.log;
root /usr/share/nginx/html;
index index.html index.htm;

location /grafana/sleep { // This is the path to my external API
    proxy_pass externaldomain.com;
    proxy_set_header Host externaldomain.com;
    proxy_set_header X-Real-IP $remote_addr; // No need to change this
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; // No need to change this
    proxy_set_header X-Forwarded-Proto $scheme; // No need to change this
    proxy_set_header Referer "https://domainOfYourGrafana.com";
}

}

So, in your request, instead of using externaldomain.com/grafana/set-pause, you can use domainOfYourGrafana.com/grafana/set-pause, and the proxy will handle the rest.