fastify / fastify-reply-from

fastify plugin to forward the current http request to another server
MIT License
148 stars 76 forks source link

Pass the request to the queryString function #364

Closed ttshivers closed 4 months ago

ttshivers commented 4 months ago

Prerequisites

🚀 Feature Proposal

It would be great to have access to the request object when passing a function for the queryString function in the same way that rewriteRequestHeaders has access to the request object.

Motivation

I'd like to be able to set the queryString based on other data present in the request including potentially injected data from a preHandler.

Example

proxy.register(require('@fastify/reply-from'), {
  base: 'http://localhost:3001/',
  queryString(search, reqUrl, req) {
    return {
      authToken: req.authToken,
    };
  },
})
mcollina commented 4 months ago

Thanks for reporting! Would you like to send a Pull Request to address this issue? Remember to add unit tests.

ttshivers commented 4 months ago

Yes I can make a PR for this.