12 likes
·
1.6K reads
7 comments
Hi Guy! Thank you very much for sharing your experience.
Did you face a CORS error while sending logs to DD from the extension? I have a problem: all requests, either from background
or content
are rejected by Datadog with the error:
Access to fetch at 'http-intake.logs.datadoghq.eu/api/v2/logs&…; from origin 'chrome-extension://*********' has been blocked by CORS policy: Request header field dd-api-key is not allowed by Access-Control-Allow-Headers in preflight response.
Postman's exact (absolutely the same) request passed successfully (code 202 and entry in Datadog).
Interesting! Generally, since the API should be accessible and must receive this header, I suspect this might be related to the endpoint you are trying to send the logs to.
I see that you are using http-intake.logs.datadoghq.eu/api/v2/logs
It's worth trying to send the requests to http-intake.logs.datadoghq.com/api/v2/logs
(.com
instead of .eu
)
Let me know if it works :)
Hi. I'm facing a similar error as well. I think this behavior might be because the API is not designed to be called from a browser. I would be grateful if you could let me know if you find any workarounds.
Unfortunately, I am also facing same issue. Works in postman, getting CORs issue from background script:
Access to fetch at 'http-intake.logs.us5.datadoghq.com/api/v2/… from origin 'chrome-extension://obdlkagmmgblbmgmflmkeop…' has been blocked by CORS policy: Request header field dd-api-key is not allowed by Access-Control-Allow-Headers in preflight response.
This blog just saved me. I had the document is not defied error for so long. Great blog, I’m sure it’s going to serve me in the future and a lot of other developers.
Just in case other people run into this:
I was getting 403's when I implemented the solution in this blog. It turns out that my company uses a different datadog enpoint than the default. So if you're using a different one, here's how to configure it:
const configuration = client.createConfiguration({
authMethods: {
apiKeyAuth: "pub...",
},
});
configuration.setServerVariables({
site: "us5.datadoghq.com"
});
const apiInstance = new v2.LogsApi(configuration);
Hi John, I would appreciate if you can elaborate on how did you find you have a different endpoint from the default.