Skip to content

req.query is not being applied into the target #47

Closed
@pjnovas

Description

@pjnovas

I'm not sure if this is supposed to happen, I'm just trying to set a querystring into the target url, here is an example to try

npm i restana fast-gateway
const restana = require("restana");
const gateway = require("fast-gateway");

const app = gateway({
  pathRegex: "",
  routes: [
    {
      prefix: "/some-path",
      target: `http://localhost:3001/some-other-path`,
      hooks: {
        async onRequest(req, res) {
          req.query = {
            some: "thing",
          };
        },
      },
    },
  ],
});

restana({})
  .get("/some-other-path", (req, res) => {
    console.log(req.query); // < here the url has no query
    res.send({});
  })
  .start(3001)
  .then(() => console.log("ready 3001"));

app
  .start(3000)
  .then(() => console.log("ready 3000 || try > http://localhost:3000/some-path"));

So getting into http://localhost:3000/some-path logs an empty object, query is not being forwarded. Is there a way of doing this?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions