How to have PathBase set so default X-Forwarded-Prefix works? #1890
-
I am trying to aggregate access to multiple applications into one using YARP, so if both applications have a route /api/version, I want to be able configure YARP to serve /app1/api/version and /app2/api/version. My applications are respecting an X-Forwarded-Prefix header when the default behaviour from the RequestHeaderXForwardedPrefixTransform is disabled and I set it manually using a RequestHeaderValueTransform. So, when app1 receives a request with a path of /app1/api/version and X-Forwarded-Prefix of /app1, it correctly routes the request to the /api/version route. Having to disable the default behaviour of RequestHeaderXForwardedPrefixTransform feels like I'm doing something wrong, but I can't see how to get PathBase set on the request in YARP to make it do what I want. Or maybe I'm totally misunderstanding the scenario that the default behaviour is supposed to be useful for? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
RequestHeaderXForwardedPrefixTransform flows HttpContext.Request.PathBase. You're not using that field in the proxy because you have two different bases, app1 and app2. Adding the x-forwarded-prefix header yourself is the correct thing to do. |
Beta Was this translation helpful? Give feedback.
RequestHeaderXForwardedPrefixTransform flows HttpContext.Request.PathBase. You're not using that field in the proxy because you have two different bases, app1 and app2. Adding the x-forwarded-prefix header yourself is the correct thing to do.
reverse-proxy/src/ReverseProxy/Transforms/RequestHeaderXForwardedPrefixTransform.cs
Line 39 in ac8fafc