Remove prefix from route before proxing? #355

Closed
opened 2025-12-29 15:21:37 +01:00 by adam · 3 comments
Owner

Originally created by @lillo42 on GitHub (Aug 26, 2021).

Hi,

Is there any way where I can remove an prefix from route before proxy it?

GIVEN The following code will proxy all GET requests made to http://:/other/service/.* to http://otherservice.com/approot
And proxyUrlPrefixToRemove transformation parameter is set to "/other/service"
WHEN running WireMock locally a request to http://localhost:8080/other/service/doc/123
THEN it would be forwarded to http://otherservice.com/approot/doc/123

Wiremock: https://github.com/tomakehurst/wiremock/issues/745
Workaround: https://gist.github.com/pavetok/62f7f0e315fcadeeae9bfcb1f8de54ad

Originally created by @lillo42 on GitHub (Aug 26, 2021). Hi, Is there any way where I can remove an prefix from route before proxy it? > GIVEN The following code will proxy all GET requests made to http://:/other/service/.* to http://otherservice.com/approot > And proxyUrlPrefixToRemove transformation parameter is set to "/other/service" > WHEN running WireMock locally a request to http://localhost:8080/other/service/doc/123 > THEN it would be forwarded to http://otherservice.com/approot/doc/123 Wiremock: https://github.com/tomakehurst/wiremock/issues/745 Workaround: https://gist.github.com/pavetok/62f7f0e315fcadeeae9bfcb1f8de54ad
adam added the question label 2025-12-29 15:21:37 +01:00
adam closed this issue 2025-12-29 15:21:38 +01:00
Author
Owner

@StefH commented on GitHub (Oct 24, 2021):

Hello @lillo42 ,

I think this can be added to WireMock.Net, like adding a new property

    "Replace" : {
        "OldValue": "/other/service",
        "NewValue": ""
    }

to
dc078b57ea/src/WireMock.Net/Settings/ProxyAndRecordSettings.cs

@StefH commented on GitHub (Oct 24, 2021): Hello @lillo42 , I think this can be added to WireMock.Net, like adding a new property ``` json "Replace" : { "OldValue": "/other/service", "NewValue": "" } ``` to https://github.com/WireMock-Net/WireMock.Net/blob/dc078b57ea463e2c9c7da7f6579af34000596446/src/WireMock.Net/Settings/ProxyAndRecordSettings.cs
Author
Owner

@StefH commented on GitHub (Nov 7, 2022):

@lillo42
Is this answer clear enough?

@StefH commented on GitHub (Nov 7, 2022): @lillo42 Is this answer clear enough?
Author
Owner

@nudejustin commented on GitHub (Apr 19, 2023):

@StefH I have raised a pull request that aims to implement your suggestion above. https://github.com/WireMock-Net/WireMock.Net/pull/924

@nudejustin commented on GitHub (Apr 19, 2023): @StefH I have raised a pull request that aims to implement your suggestion above. https://github.com/WireMock-Net/WireMock.Net/pull/924
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/WireMock.Net-wiremock#355