coder / code-server

VS Code in the browser
https://coder.com
MIT License
67.74k stars 5.56k forks source link

[Bug]: Code server not work for POST (Apollo GraphQL) #5669

Closed Drilmo closed 1 year ago

Drilmo commented 1 year ago

Is there an existing issue for this?

OS/Web Information

Steps to Reproduce

  1. open code-server
  2. run Apollo GraphQL local with integrated terminal ( port 4001 and path /local/graphql)
  3. go to url domain/proxy/4001/local/graphql (GET work)
  4. call url domain/proxy/4001/local/graphql with POST not work

Expected

call url domain/proxy/4001/local/graphql with POST work

Actual

Just get work

Logs

No response

Screenshot/Video

No response

Does this issue happen in VS Code or GitHub Codespaces?

Are you accessing code-server over HTTPS?

Notes

No response

jsjoeio commented 1 year ago

Can you provide a repo to reproduce this? Happy to look into it!

Drilmo commented 1 year ago

Can you provide a repo to reproduce this? Happy to look into it!

@jsjoeio you can use this repo to reproduce : https://github.com/Drilmo/test

jsjoeio commented 1 year ago

Thank you!

So I cloned and ran npm install:

npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/@data-in-motion%2fauto-changelog - Not found
npm ERR! 404 
npm ERR! 404  '@data-in-motion/auto-changelog@^1.0.1' is not in this registry.
npm ERR! 404 
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/jp/.npm/_logs/2022-10-20T17_17_29_577Z-debug-0.log

Decided to try this and then when i access at localhost:8080/proxy/4000 I see the playground as expected:

image

Then I added router.yaml with this:

#
# supergraph: Configuration of the Supergraph server
#
supergraph:
  # The path for GraphQL execution
  # (Defaults to /)
  path: /graphql

and I was still able to access it, using localhost:8080/proxy/4000/graphql

image

Are you using a relative path?

Drilmo commented 1 year ago

@jsjoeio sorry for my mistake, for the bug on "npm i" I have push fix (just remove dependance) I don't use Apollo Router because I use Apollo Federation and this sample is a subgraph. it work on my local but not on local of code-server

Drilmo commented 1 year ago

@jsjoeio I forgot to specify 😅 I am on an EC2 AWS ubuntu but I used the ubuntu installer. Also I am using serverless framework to run lambda, as well as a DynamoDB locally.

jsjoeio commented 1 year ago

@Drilmo ahhh got it! What's the simplest way to run only the Apollo part? That way we can isolate it and see if there's something wrong with Apollo (and so i don't have to spin up an EC2 instance 😅)

Drilmo commented 1 year ago

@jsjoeio, you can do this if you follow the readme on your code-server, this launch Apollo locally (with AWS).

But you need access key and secret key for aws-cli (on your code server) (it's free for local launch).

Have you access key and secret key ? (if you haven't I can share you the necessary, but by another way than this chat for a minimum of security)

Sorry if my English isn't perfect (I'm French)

jsjoeio commented 1 year ago

Is there a way to launch Apollo locally without AWS? I want to figure out where the problem is coming from.

Sorry if my English isn't perfect (I'm French)

Oh don't worry - I didn't even notice!

Drilmo commented 1 year ago

Is there a way to launch Apollo locally without AWS? I want to figure out where the problem is coming from.

@jsjoeio I just tried in standalone server mode (without serverless framework - AWS) and it works 😭 The problem occurs when I use the local aws part 😓 started with serverless framework

Drilmo commented 1 year ago

@jsjoeio When I use serverless framework for local AWS Lambda I have this log :

image

And when I go to the url https://my-domain/proxy/4001/local/graphql it's work (for the GET) :

Capture d’écran 2022-10-21 à 09 54 46

and I see my request in the log :

image

But when I try to use curl on bottom (POST request) of the previous screen I don't see anything on log.

And if I click on "query your server" button, I can't contact the service with a POST request :

Capture d’écran 2022-10-21 à 10 01 03

you can see red indicator.

jsjoeio commented 1 year ago

Hmm...I wish I could be more helpful but I don't think we'll get to the bottom of this unless we can run Apollo without AWS in the equation. Based on what you've shared, I would bet there is something off about the expected path on Apollo's side. Maybe it's expecting an absolute URL instead of a relative one.

Two other ideas: what does curl log when you do the POST request?

Also when you're in the browser and see the red indicator, what browser logs do you see? what do you see in the network tab?

Drilmo commented 1 year ago

@jsjoeio do you think I can call you and share my screen for testing or anything else ?

jsjoeio commented 1 year ago

No, but you could record a screencast and post the video here!

Drilmo commented 1 year ago

@jsjoeio i have found my mistake ! I have juste an old version of Serverless-offline dependency