Closed jkyberneees closed 2 years ago
Hi @sPaCeMoNk3yIam, thanks for pointing to this feature/issue/non-configurable-option topic.
So far
fast-gateway
have allowed devs to extend thereq.query
object (through middlewares) before the request is proxied to it's target. This is why I can't just disable this feature.In order to disable this feature at route level, I have introduced a new
disableQsOverwrite
route configuration. By setting it totrue
, the raw query string will be used instead.Example:
{ prefix: '/qs-no-overwrite-service', disableQsOverwrite: true, target: 'http://localhost:3000', hooks: { onRequest: (req) => { // req.query modifications are discarded req.query.name = 'fast-gateway' } } }
As you can see, there is no need to re-parse again the query string:
queryString: route.disableQsOverwrite ? null : req.query // see null
As an alternative, you can always add your custom query string parser as a global middleware in fast-gateway.
Would you consider this update a solution to your issue? I look forward to your feedback.
Closes: #80, #81
Best Regards
Hi @jkyberneees! Thanks for getting back to this that quickly. I totally like the idea that query
is configurable, the upstream could expect another format or values. Not sure though how well this plays together with fast-proxy-lite
as this does the serialization in the end (and is the standard proxy).
For now, having this flag is totally fine. So I think it should be covered with some specs?
Hi @sPaCeMoNk3yIam, thanks for pointing to this feature/issue/non-configurable-option topic.
So far
fast-gateway
have allowed devs to extend thereq.query
object (through middlewares) before the request is proxied to it's target. This is why I can't just disable this feature.In order to disable this feature at route level, I have introduced a new
disableQsOverwrite
route configuration. By setting it totrue
, the raw query string will be used instead.Example:
As you can see, there is no need to re-parse again the query string:
queryString: route.disableQsOverwrite ? null : req.query // see null
As an alternative, you can always add your custom query string parser as a global middleware in fast-gateway.
Would you consider this update a solution to your issue? I look forward to your feedback.
Closes: https://github.com/BackendStack21/fast-gateway/issues/80, https://github.com/BackendStack21/fast-gateway/pull/81
Best Regards