I am trying to generate grafana dashboard by calling the spring REST API using simple-json-datasource. Implemented all required APIs (/, /search, /query) for enabling simple-json-datasource and maintained the contract as expected by grafana simple-json-datasource.
Also, added the CORS as part of response header and even enabled the CORS for the request API by adding the @CrossOrigin at ****@RestController**.
When i test the APIs, i am getting following header information in the response of the call { “access-control-allow-headers”: “Content-Type, Accept”, “access-control-allow-methods”: “POST, GET”, “access-control-allow-origin”: “*”, “connection”: “keep-alive”, “content-type”: “application/json”, “date”: “Thu, 14 May 2020 16:51:18 GMT”, “keep-alive”: “timeout=60”, “transfer-encoding”: “chunked”, “vary”: “Origin, Access-Control-Request-Method, Access-Control-Request-Headers” }
But while creating the datasource by pointing to /, i was getting the below error
Access to XMLHttpRequest at ‘http://localhost:8888/streams/api/’ from origin ‘http://localhost:3000’ has been blocked by CORS policy: The ‘Access-Control-Allow-Origin’ header contains multiple values ‘*, *’, but only one is allowed.
Input request for the API call is : curl -X GET --header ‘Accept: application/json’ ‘http://localhost:8888/streams/api/’
Any clue?