-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Catch unauthenticated POST requests to the proxy and return an error instead of redirecting to vs code #2128
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
Comments
You could maybe try the same thing by accessing code-server directly and not through a reverse proxy. What do the browser devtools (the network tab especially) say about the POST requests? https://github.com/cdr/code-server/blob/v3.5.0/doc/guide.md#nginx |
Thanks for you input on this, I just tried to leave away my reverse proxy, and directly access http://INTERNALIP:8080/proxy/3000/graphql so no other reverse proxy should be involved, except the one provided as part of code-server. I know for sure that the express + apollo server listening on port 3000 on that host machine wouldn't have any issues to parse POST requests. I just looked it up in the code, and it's probably related to this: All
An external library,
|
What request is giving the 400 and |
@code-asher I don't think so, I'm using the proxied subdomain feature, So in my case, running GraphQL Playground works fine and comes up on: Inspecting the network tab, they seem to go right where they are supposed to, |
Aaahh I only tested the sub-path proxy method. I'll test the sub-domain method and see if I can reproduce. |
Hmm I haven't had luck replicating so far. Here's what I did to test (all local): Ran httpbin which lets you test various HTTP requests:
Started up code-server:
In my case Then ran a POST request through code-server's proxy (this can also be done from httpbin's web interface):
I'll give graphql a try as well, just need to get familiar with it a bit so I can get it running. |
I loaded up some data and ran a query and it appears to be working. I tried both the playground interface and cURL:
I used this example: https://codesandbox.io/s/node-apollo-graphql-7sgx4 and ran it locally on port 8082 then accessed it through code-server's proxy. Any idea on how this might be different from your setup? |
@code-asher Thanks for testing, I‘ll do some more testing aswell with other containers maybe. |
Ah yeah good point, I'll give it a go with auth on. |
I'm still able to POST with httpbin but when I load up the graphql playground I get the When unauthenticated we skip the proxy so it'll try to load VS Code instead which doesn't support As for why it fails, it looks like the default for credentials is
Relevant docs: https://www.apollographql.com/docs/apollo-server/testing/graphql-playground/#configuring-playground |
That may or may not be helpful for you though since you mentioned your POST requests are already including the cookie. In that case I think there must be some other reason code-server isn't properly authenticating these requests. |
@code-asher Thanks for taking the time to investigate this! So the only issue seems to be the wrong message that is returned, I updated the title to reflect that. |
Huh, turns out I had already fixed this in master. It'll be in the 3.6.0 release!! |
Actually although it properly shows the authentication error now it still needs to be a bit smarter and redirect to the login page when the root page is requested if necessary. |
I'm trying to proxy POST calls for a graphql api running on my dev instance, but when I do POST requests, I always recieve:
{"error":"Unsupported method POST"}
Visiting pages / GET requests work fine.
I assume this to be a restriction in the proxy, but didn't take a deeper look yet.
The text was updated successfully, but these errors were encountered: