Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Intercept and reject requests based on body content #244

Closed
ortonomy opened this issue Feb 18, 2018 · 2 comments
Closed

Intercept and reject requests based on body content #244

ortonomy opened this issue Feb 18, 2018 · 2 comments

Comments

@ortonomy
Copy link

I want to be able to intercept and reject a request through the proxy by examining body content.

For example, my request coming through is a grapql query or mutation in body of POST

mutation {
  registerUser ( ... ) {
    ...
  }
}

and I want to be able to examine the content body for registerUser (or something else) and reject with a 403 - Forbidden.

I feel it's similar, but the opposite to here: #97

So I'd like to use onProxyReq, but I dont' know how to read the body and then make an action using req / res. Anyone can help?

@stevenkissack
Copy link

Did you ever resolve this? I am trying to do the exact same. I also want to modify the graphql query in certain cases, and reject all mutations

@chimurai
Copy link
Owner

You might want to try using a library like nock.
It has tons of options to control the response.

The following example will just respond with 403 on every graphql request.

var scope = nock('http://my.domain.com')
  .intercept('/graphql', 'POST')
  .reply(403);

Check their documentation for more fine grained control.

Please let us know if you have any succes with nock.

Repository owner locked and limited conversation to collaborators Apr 18, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants