0

I am setting up a reverse proxy server with node-http-proxy and wanted to know how to pass in a variable to change the outbound request on a per-request basis. I want to make all my calls to the proxy server located at http://localhost:8000 and pass in an "extension" of sorts to the target url of the outbound requests.

For example, the target url of the real server the proxy server is calling on is at http://localhost:9999, and I want to add an extension of /config to that url. So from my front end I would fetch from http://localhost:8000 and pass in the /config extension, and the proxy server would call http://localhost:9999/config for this particular case. Does anyone know how I might go about passing in this string?

Thank you for your help.

4
  • Does it work if you just change the target to http://localhost:9999/config/? Commented Jul 9, 2021 at 16:57
  • Yes it works. But the extension is going to change depending on what I need. So it could be /users, /orgs, etc. If I change the target manually to any of them it works but I need it to change based on what the front-end needs Commented Jul 9, 2021 at 17:13
  • Just figured out how to change the target path URL, but still need help passing in the "extension" Commented Jul 9, 2021 at 17:19
  • So frontend asks for /users or /orgs and you want it to be /config/users and /config/orgs? Or do you mean that depending on which path is requested, you want to modify the path prefix ('/config') on the fly? If so, check out the documentation section on custom logic Commented Jul 9, 2021 at 17:22

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.