My FeedDiscussionsHashnode Enterprise
New
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMS for Enterprise.
Upgrade ✨Learn more
Guy Goldenberg

12 likes

·

1.6K reads

7 comments

Sergiy Voznyak
Sergiy Voznyak
Nov 9, 2023

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).

3
·
·3 replies
Guy Goldenberg
Guy Goldenberg
Author
·Nov 28, 2023

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 :)

·
Yuki Oshima
Yuki Oshima
Mar 21, 2024

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.

·
Sargis
Sargis
Jun 26, 2024

Guy Goldenberg

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.
·
Yonatan Eilat
Yonatan Eilat
Jul 25, 2023

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.

1
·
John Gordon
John Gordon
Feb 1, 2024

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);
·
·1 reply
Aviv Elmakias
Aviv Elmakias
Mar 24, 2024

Hi John, I would appreciate if you can elaborate on how did you find you have a different endpoint from the default.

·