Skip to content

Bug: Using Sourcegraph.com GraphQL API from other websites is broken

Created by: slimsag

Problem: If you try to use https://sourcegraph.com/.api/graphql from another website, it is blocked due to CORS because we're not setting any Content-Security-Policy for responses from that URL, it defaults and is thus blocked:

Content Security Policy: The page’s settings blocked the loading of a resource at https://sourcegraph.com/.api/graphql?SearchContexts (“default-src”).

Are you ready for some history?

In short:

  1. https://sourcegraph.com/.api/graphql should have a Content-Security-Policy which allows requests from any origin.
  2. This should be completely safe and secure to enable, and was the original intended behavior - but obviously needs verification.