Added api-key header.

This commit is contained in:
Michael Mainguy 2023-08-15 10:12:56 -05:00
parent c54ce61395
commit 4cd0423578

View File

@ -7,7 +7,7 @@ export const handler: Handler = async (event: HandlerEvent, context: HandlerCont
case 'POST': case 'POST':
const apiKey = event.headers['api-key']; const apiKey = event.headers['api-key'];
const query = event.body; const query = event.body;
const response = await axios.post('https://api.newrelic.com/graphql', // use account token to get a temp user token const response = await axios.post('https://api.newrelic.com/graphql',
query, query,
{headers: {'Api-Key': apiKey, 'Content-Type': 'application/json'}}); {headers: {'Api-Key': apiKey, 'Content-Type': 'application/json'}});
const data = await response.data; const data = await response.data;
@ -20,7 +20,7 @@ export const handler: Handler = async (event: HandlerEvent, context: HandlerCont
case 'OPTIONS': case 'OPTIONS':
const headers = { const headers = {
'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Headers': 'Content-Type', 'Access-Control-Allow-Headers': 'Content-Type, Api-Key',
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE' 'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE'
}; };
return { return {