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
I had the same problem with a canvas button that should send a POST to a minimal http server. Both Grafana and the web server were running on the same machine, under Linux Mint.
Several different errors regarding the “no ‘Access-Control-Allow-Origin’ header” were reported, depending on how I wrote the host name.
The problem was in the /etc/hosts file where these two lines were found:
127.0.0.1 localhost
127.0.1.1 minimint
I changed this to the following and that solved the problem:
127.0.0.1 localhost minimint
There seems to be a problem in the CORS system where the origin name handler is confused when the same machine has two different IP adresses.
The idea behind the 127.0.1.1 address is that it is a placeholder until the machine is assigned a fixed IP address. AFAIK this is common to at least all Debian Linux installations.
Having both Grafana and the web server on the same machine is quite common during development, but I found no other mention of the problem being in the /etc/hosts file. I’ve not had any problems with either Linux or Grafana (yet) after changing the hosts file.