Proxying always goes to the root #579

Closed
opened 2025-12-29 08:30:31 +01:00 by adam · 1 comment
Owner

Originally created by @JorisVanEijden on GitHub (Mar 1, 2024).

Originally assigned to: @StefH on GitHub.

Describe the bug

ProxyAndRecordSettings.Url = "https://www.example.com/some/sub/paths"

A request for "/someurl" is proxied to "https://www.example.com/someurl"

Expected behavior:

A request for "/someurl" is proxied to "https://www.example.com/some/sub/paths/someurl"

The path to proxy to is determined by var proxyUriWithRequestPathAndQuery = new Uri(proxyUri, requestUri.PathAndQuery);
Since requestUri.PathAndQuery will always start with a slash, the created uri will always only take the root of the proxyUri and ignore the sub paths.

*edit: A workaround:

ReplaceSettings = new ProxyUrlReplaceSettings
{
  OldValue = "example.com/",
  NewValue = "example.com/some/sub/paths/",
}
Originally created by @JorisVanEijden on GitHub (Mar 1, 2024). Originally assigned to: @StefH on GitHub. ### Describe the bug ProxyAndRecordSettings.Url = "https://www.example.com/some/sub/paths" A request for "/someurl" is proxied to "https://www.example.com/someurl" ### Expected behavior: A request for "/someurl" is proxied to "https://www.example.com/some/sub/paths/someurl" ### Other related info The path to proxy to is determined by `var proxyUriWithRequestPathAndQuery = new Uri(proxyUri, requestUri.PathAndQuery);` Since `requestUri.PathAndQuery` will always start with a slash, the created uri will always only take the root of the `proxyUri` and ignore the sub paths. *edit: A workaround: ``` c# ReplaceSettings = new ProxyUrlReplaceSettings { OldValue = "example.com/", NewValue = "example.com/some/sub/paths/", } ```
adam added the question label 2025-12-29 08:30:31 +01:00
adam closed this issue 2025-12-29 08:30:31 +01:00
Author
Owner
@StefH commented on GitHub (Mar 2, 2024): Hi @JorisVanEijden The ProxyUrlReplaceSettings are indeed the correct way to implement your requirements. See also this unit-test: https://github.com/WireMock-Net/WireMock.Net/blob/master/test/WireMock.Net.Tests/WireMockServer.Proxy.cs#L574 See also these issues and PR's - #924 - #925 - #630 - #1026
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/WireMock.Net#579