question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Calls are being made to localhost, instead of given uri, using new HttpLink()

See original GitHub issue

Intended outcome:
Http calls go to https://actual-website.com/graphql/.

Actual outcome:
Http calls are being made to http://localhost:3000/graphql/. Console errors:

POST http://localhost:3000/graphql 404 (Not Found)

Unhandled (in react-apollo:Apollo(DomainsView)) Error: Network error: Unexpected token < in JSON at position 0
    at new ApolloError (http://localhost:3000/main.js:39001:28)
    at ObservableQuery.currentResult (http://localhost:3000/main.js:38445:24)
    at GraphQL.dataForChild (http://localhost:3000/main.js:34830:62)
    at GraphQL.render (http://localhost:3000/main.js:34880:33)
    at http://localhost:3000/main.js:71999:21
    at measureLifeCyclePerf (http://localhost:3000/main.js:71279:12)
    at ReactCompositeComponentWrapper._renderValidatedComponentWithoutOwnerOrContext (http://localhost:3000/main.js:71998:25)
    at ReactCompositeComponentWrapper._renderValidatedComponent (http://localhost:3000/main.js:72025:32)
    at ReactCompositeComponentWrapper._updateRenderedComponent (http://localhost:3000/main.js:71949:36)
    at ReactCompositeComponentWrapper._performComponentUpdate (http://localhost:3000/main.js:71927:10)

How to reproduce the issue:
In the following codesandbox I’ve loaded the exact same versions of apollo packages I use in my own app. The error also occurs here, except the url called seems to default to https://n7z74xx7oj.codesandbox.io/graphql, instead of the given https://qkv3mq9rp.lp.gql.zone/graphql. I also cannot seem to find the Authorization header in the requests. https://codesandbox.io/s/n7z74xx7oj

Version

  • apollo-boost@0.1.1
  • apollo-client@2.2.5
  • apollo-link@1.2.1
  • apollo-link-context@1.0.7
  • apollo-link-http@1.5.1
  • graphql@0.12.3

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:14 (1 by maintainers)

github_iconTop GitHub Comments

39reactions
peterschrievercommented, Feb 26, 2018

Apologies, it seems that I was using the wrong import statements;
What I had: import ApolloClient from 'apollo-boost';. What fixed it for me (which is also what is written in the docs): import { ApolloClient } from 'apollo-client';.

Not sure how I got this wrong…

11reactions
joshdotblackcommented, Aug 22, 2018

Ignore me, I noticed the typo url instead of uri, I’ll go back to shouting at clouds and telling kids to get off my lawn! 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

HTTP Link - Apollo GraphQL Docs
A function to use instead of calling the Fetch API directly when sending HTTP requests to your GraphQL endpoint. The function must conform...
Read more >
Access to fetch at 'http://localhost:6969/graphql' from origin ' ...
If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled. I am learning...
Read more >
Automatically handling Apollo Client errors in your React UI
new HttpLink ({ uri: "http://localhost:4000" }) ... occurs in a hook and there's no specific error handling being done at that call-site, ...
Read more >
http.client — HTTP protocol client — Python 3.11.1 ...
An HTTPConnection instance represents one transaction with an HTTP server. ... _create_unverified_context() can be passed to the context parameter.
Read more >
Using Apollo to Query GraphQL from Node.js
Getting Started. First, let's get all our files and dependencies in place. Create a folder called nodejs-apollo-client and open it in your ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found