Skip to content
This repository has been archived by the owner on Nov 19, 2023. It is now read-only.

Relative forward? #62

Open
AAverin opened this issue Aug 1, 2018 · 1 comment
Open

Relative forward? #62

AAverin opened this issue Aug 1, 2018 · 1 comment
Labels

Comments

@AAverin
Copy link

AAverin commented Aug 1, 2018

I would like to use single toxy instance to throttle many different APIs.
I am trying to set up following:

proxy.all("/papyrus")
    .forward("https://server1")
    .poison(poisons.latency({ min: 50, max: 2000 }))

proxy.all("/gql/*")
    .forward("https://server2")

Problem is, part of the url in all is also being forwarded

Any way to forward excluding the base url in all?

@h2non
Copy link
Owner

h2non commented Aug 1, 2018

You can write a middleware for that route where you can rewrite and strip the incoming request path, such as:

proxy.all("/papyrus")
    .use((req, res, next) => {
      req.url = '/'
      next()
    })
    .forward("https://server1")
    .poison(poisons.latency({ min: 50, max: 2000 }))

@h2non h2non added the question label Aug 1, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants