Getting CORS error when trying to log error in node (request header field x-apikey is not allowed...)
swanRAGE
Posted on
Mar 15 2016
I am trying to use raygun in node but keep getting the following error when calling the line of code that logs an error:
Fetch API cannot load https://api.raygun.io/entries. Request header field x-apikey is not allowed by Access-Control-Allow-Headers in preflight response.
Here's my initialization code:
logger.js
/* eslint no-process-env: 0 */ const raygun = require('raygun');
const logger = new raygun.Client().init({ apiKey: 'api key value' });
module.exports = logger;
Example use of trying to log error:
import logger from '../lib/logger.js'; }).catch(error => { logger.send(error); });
Any idea why this is happening? I cannot find anything comparable online. This is happening in a local/debug environment running an express server on localhost.
Daniel
Posted on
Mar 16 2016
Hey Zach,
Hmm that's odd - are you using something to filter outgoing requests from Node by any chance? The library uses standard Node HTTP requests to talk to the api.
Here's a quick GIST with a working Node app
https://gist.github.com/dwnz/eeb7ee9ec25f923bdc6b
Cheers, Daniel