V2 CORS Support


#1

Is there no CORS support? I am receiving an error in preflight “No ‘Access-Control-Allow-Origin’ header is present on the requested resource”. Sample javascript code below (with API key removed) pasted below. Thanks in advance for any assistance.

var OS_KEY = ‘xxxxxxxxx’; // Actual API key filled in
var API_url = ‘https://openstates.org/graphql’;
var myQuery = ‘{people(first: 3){edges{node{name}}}}’;

var myHeaders = new Headers();
myHeaders.append(‘Accept’, ‘application/json’);
myHeaders.append(‘Content-Type’, ‘application/json’);
myHeaders.append(‘X-API-KEY’, OS_KEY);

fetch(API_url, {
method: ‘POST’,
mode: ‘cors’,
headers: myHeaders,
body: JSON.stringify({query: myQuery}),
})