Skip to content

Instantly share code, notes, and snippets.

@jgoux
Last active January 16, 2019 15:26
Show Gist options
  • Save jgoux/f58347b796f9d2fa31e881002f69ab91 to your computer and use it in GitHub Desktop.
Save jgoux/f58347b796f9d2fa31e881002f69ab91 to your computer and use it in GitHub Desktop.
Proxy issue with Gatsby

During development, I want to be able to proxy my GraphQL queries to my own GraphQL server at http://localhost:3000/graphql

I configured Gatsby like this :

module.exports = {
  proxy: {
    prefix: '/graphql',
    url: 'http://localhost:3000'
  }
}

Gatsby's development server is running at http://localhost:8000

My queries aren't proxied, they fired on http://localhost:8000/graphql and I got the empty index.html content as a response :

<!DOCTYPE html><html><head><meta charSet="utf-8"/><meta http-equiv="x-ua-compatible" content="ie=edge"/><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/><script src="/socket.io/socket.io.js"></script></head><body><noscript id="gatsby-noscript">This app works best with JavaScript enabled.</noscript><div id="___gatsby"></div><script src="/commons.js"></script></body></html>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment