Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

400 (Bad Request) in relay-treasurehunt example #388

Closed
happypoulp opened this issue Sep 25, 2015 · 4 comments
Closed

400 (Bad Request) in relay-treasurehunt example #388

happypoulp opened this issue Sep 25, 2015 · 4 comments
Assignees

Comments

@happypoulp
Copy link

Hi,

I can't get the relay-treasurehunt example to work. I get this errors when loading http://localhost:3000 into my chrome browser:

treasure-hunt graphql errors

I am running node v4.1.0 on a Mac os x Yosemite 10.10.3, chrome Version 45.0.2454.99 (64-bit) and Relay master branch at commit d2c821e.

I ran npm run update-schema then npm install and finally npm start to run the example server. Did I miss something?

Thanks.

@josephsavona
Copy link
Contributor

I can't repro this locally on master

@happypoulp
Copy link
Author

I just took the last master and the issue is still here. What's weird is that the graphQL server is supposed to run on http://localhost:8080 but the screenshot above shows that graphQL requests that fail are emitted on http://localhost:3000/graphQL. Below is the same request, reproduced via curl:

(bash) $ curl 'http://localhost:3000/graphql' -H 'Pragma: no-cache' -H 'Origin: http://localhost:3000' -H 'Accept-Encoding: gzip, deflate' -H 'Accept-Language: en-US,en;q=0.8,it;q=0.6' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36' -H 'content-type: application/json' -H 'Accept: */*' -H 'Cache-Control: no-cache' -H 'Referer: http://localhost:3000/' -H 'Connection: keep-alive' --data-binary '{"query":"query AppHomeRoute{game{id,...__RelayQueryFragment024i1nd}} fragment __RelayQueryFragment1zhzqzq on HidingSpot{id} fragment __RelayQueryFragment2cbpjvm on Game{id,turnsRemaining} fragment __RelayQueryFragment024i1nd on Game{turnsRemaining,_hidingSpots1f5uhj:hidingSpots(first:9){edges{node{hasBeenChecked,hasTreasure,id,...__RelayQueryFragment1zhzqzq},cursor},pageInfo{hasNextPage,hasPreviousPage}},id,...__RelayQueryFragment2cbpjvm}","variables":{}}' --compressed

            <html>
                <head>
                    <title>400 Bad Request</title>
                </head>
                <body>HttpError('Invalid HTTP request form (expected: absolute, got: relative)',)</body>
            </html>

And here the same request but played on 8080 port (it works correctly):

(bash) $ curl 'http://localhost:8080/graphql' -H 'Pragma: no-cache' -H 'Origin: http://localhost:3000' -H 'Accept-Encoding: gzip, deflate' -H 'Accept-Language: en-US,en;q=0.8,it;q=0.6' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36' -H 'content-type: application/json' -H 'Accept: */*' -H 'Cache-Control: no-cache' -H 'Referer: http://localhost:3000/' -H 'Connection: keep-alive' --data-binary '{"query":"query AppHomeRoute{game{id,...__RelayQueryFragment024i1nd}} fragment __RelayQueryFragment1zhzqzq on HidingSpot{id} fragment __RelayQueryFragment2cbpjvm on Game{id,turnsRemaining} fragment __RelayQueryFragment024i1nd on Game{turnsRemaining,_hidingSpots1f5uhj:hidingSpots(first:9){edges{node{hasBeenChecked,hasTreasure,id,...__RelayQueryFragment1zhzqzq},cursor},pageInfo{hasNextPage,hasPreviousPage}},id,...__RelayQueryFragment2cbpjvm}","variables":{}}' --compressed
{
  "data": {
    "game": {
      "id": "R2FtZTox",
      "turnsRemaining": 3,
      "_hidingSpots1f5uhj": {
        "edges": [
          {
            "node": {
              "hasBeenChecked": false,
              "hasTreasure": null,
              "id": "SGlkaW5nU3BvdDow"
            },
            "cursor": "YXJyYXljb25uZWN0aW9uOjA="
          },
          {
            "node": {
              "hasBeenChecked": false,
              "hasTreasure": null,
              "id": "SGlkaW5nU3BvdDox"
            },
            "cursor": "YXJyYXljb25uZWN0aW9uOjE="
          },
          {
            "node": {
              "hasBeenChecked": false,
              "hasTreasure": null,
              "id": "SGlkaW5nU3BvdDoy"
            },
            "cursor": "YXJyYXljb25uZWN0aW9uOjI="
          },
          {
            "node": {
              "hasBeenChecked": false,
              "hasTreasure": null,
              "id": "SGlkaW5nU3BvdDoz"
            },
            "cursor": "YXJyYXljb25uZWN0aW9uOjM="
          },
          {
            "node": {
              "hasBeenChecked": false,
              "hasTreasure": null,
              "id": "SGlkaW5nU3BvdDo0"
            },
            "cursor": "YXJyYXljb25uZWN0aW9uOjQ="
          },
          {
            "node": {
              "hasBeenChecked": false,
              "hasTreasure": null,
              "id": "SGlkaW5nU3BvdDo1"
            },
            "cursor": "YXJyYXljb25uZWN0aW9uOjU="
          },
          {
            "node": {
              "hasBeenChecked": false,
              "hasTreasure": null,
              "id": "SGlkaW5nU3BvdDo2"
            },
            "cursor": "YXJyYXljb25uZWN0aW9uOjY="
          },
          {
            "node": {
              "hasBeenChecked": false,
              "hasTreasure": null,
              "id": "SGlkaW5nU3BvdDo3"
            },
            "cursor": "YXJyYXljb25uZWN0aW9uOjc="
          },
          {
            "node": {
              "hasBeenChecked": false,
              "hasTreasure": null,
              "id": "SGlkaW5nU3BvdDo4"
            },
            "cursor": "YXJyYXljb25uZWN0aW9uOjg="
          }
        ],
        "pageInfo": {
          "hasNextPage": false,
          "hasPreviousPage": false
        }
      }
    }
  }
}

Since I did not touch in any way to the code of the example, how does it come that graphQL requests are emitted on the wrong domain (localhost:3000 instead of localhost:8080)? Is it there anything I can do to pinpoint the issue more precisely?

Thanks!

@happypoulp
Copy link
Author

Ok I found the issue. It was a local mitmproxy install (https://mitmproxy.org/) that was somehow messing with my request to graphql. Not sure why but after un-installing it, the example works correctly.

Thanks.

@wincent
Copy link
Contributor

wincent commented Oct 7, 2015

Glad to hear that you got to the bottom of this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants