Setup CORS policy for grafana

hey everyone!!

localhost/:1 Access to XMLHttpRequest at ‘http://127.0.0.1:8080/api/v1/provisioning/contact-points’ from origin ‘http://localhost:5001’ has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.

getting the above error when trying to call the grafana api from a localhost server

Try to configure [server.custom_response_headers] where you will define all allow headers for cors/preflight response.

# This setting enables you to specify additional headers that the server adds to HTTP(S) responses.
[server.custom_response_headers]
#exampleHeader1 = exampleValue1
#exampleHeader2 = exampleValue2

In the worst case use yiur favorite reverse proxy in front of Grafana and configure/allow cors on the proxy level.

1 Like

@jangaraj
Tried to configure [server.custom_response_headers] but this didn’t took effect.
So now i’ll try to use Nginx as a reverse proxy.

hey everyone

i am not able to configure nginx for grafana
how to configure and test
any leads ? please help