dgraph-io / dgraph-io/dgraph

Adding Sentry to codebase results in Dgraph throwing CORS errors

Open
#9,529 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Stale
Dominant language
Go
Stars
21.8k
Forks
1.6k
Avg merge
2d 5h
Merged PRs (30d)
9

Description

Discussed in https://github.com/orgs/dgraph-io/discussions/8916

Originally posted by benwoodward July 24, 2023

Access to fetch at 'http://localhost:8080/graphql' from origin 'http://localhost:5173' has been blocked by CORS policy: Request header field baggage is not allowed by Access-Control-Allow-Headers in preflight response.

Sentry adds a Baggage header (as well as sentry-trace), and they suggest that you configure your backend server to allow these headers, however, I don't think there's a way to do that in Dgraph? Should this be a feature request?

It seems I should be able to add the following to my schema, but I can't:

# Dgraph.Allow-Headers baggage

For the time being, I will write some logic that intercepts any requests to Dgraph and strips the headers.

EDIT: Here's how to prevent the headers from being added to specific requests:

python: https://docs.sentry.io/platforms/python/usage/distributed-tracing/limiting-trace-propagation/
js: https://docs.sentry.io/platforms/javascript/performance/instrumentation/automatic-instrumentation/

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at Dgraph's GraphQL endpoint and its CORS handling, then inspect how preflight responses treat the baggage and sentry-trace headers. Determine whether a supported configuration path is needed, and verify that a request from http://localhost:5173 no longer fails with the reported CORS error.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, graphql
Domain
api
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.