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

Provide a possibility to validate request payload before proxying the request #311

Closed
2 tasks done
kovalenp opened this issue Jul 20, 2023 · 2 comments
Closed
2 tasks done

Comments

@kovalenp
Copy link
Contributor

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the feature has not already been requested

🚀 Feature Proposal

I would like to have the possibility to validate the request payload before proxying it further.

E.g.

Currently, request.body in preHandler is a stream

.register(require('@fastify/http-proxy'), {
      upstream: process.env.API,
      prefix: '/v1/:domain/:apiKey',
      rewritePrefix: '/full/:domain',
    })

so I can't have something like this:

.register(require('@fastify/http-proxy'), {
      upstream: process.env.API,
      prefix: '/v1/:domain/:apiKey',
      rewritePrefix: '/full/:domain',
      preHandelr: (req) => { validate(req.body)}
    })

Motivation

I have and rpc api which I'm proxying via http-proxy. I would like to check request json payload and restrict certain methods (not to proxy it further and reply with error)

I have no possibility to do so, since request.body is not parsed in preHander.

Example

No response

@kovalenp
Copy link
Contributor Author

See fastify/help#906

@Eomm
Copy link
Member

Eomm commented Jul 20, 2023

Thanks for reporting!
It is in the roadmap: https://github.com/fastify/fastify-http-proxy#todo

Would you like to send a Pull Request to address this feature?

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

2 participants