https://linen.dev logo
#help
Title
# help
j

Jackie chen

06/07/2023, 7:31 AM
Hello i’m running WireMock as a server (WireMockServer) and use the enableBrowserProxying=true, i would like to know how to return a stub response when the request is not matched. currently it’s always passing the request to the external url. Consuming application sends this request with stub server as forward proxy e.g. Request url https://www.sample.com/api/pattern proxy: stub-server-host:4000 Wiremock should return http 404 when the request pattern /api/pattern does not match with any stub mapping Is it correct that the following payload must be sent to the API { ... “proxyPassThrough”: false } What is the full request payload and wiremock rest api url for this?
t

Tom

06/07/2023, 8:34 AM
Hi Jackie,
proxyPassThrough
is a startup and global settings parameter. The easiest way to set it is at startup, so
--proxy-pass-through=false
on the CLI or
proxyPassThrough(false)
in the options builder if you’re starting programmatically.
Another option if you want to customise the 404 response is to create a stub that matches any method, any URL, has low priority e.g. 9 and returns whatever 404 response you want.
j

Jackie chen

06/07/2023, 8:40 AM
Hi @Tom i’m using wiremock-jre8 2.33.2 and don’t see the proxyPassThrough api in the WireMockConfiguration class which i would like to start it programmatically. could you please suggest?
t

Tom

06/07/2023, 8:41 AM
You’ll need to use the latest 3.x version to access this parameter
4 Views