Mocklets
  • Getting Started
  • Working with Collections
    • Create Collection
    • Invite Members
  • Managing Mock Apis
    • Dynamic Responses
    • URL Regex Matching
    • Use API as Proxy
    • Randomised Responses
    • Response Delay
    • Using Query Params
    • API Comments
  • Manage your files
  • Open API Specifications 3.x
  • Integration with external editors
  • Response Headers
  • Monitor Request Logs
  • Secure your mock APIs
  • Important Links
    • Home
    • Dashboard
    • Privacy Policy
    • Terms of Use
Powered by GitBook
On this page

Was this helpful?

  1. Managing Mock Apis

Use API as Proxy

PreviousURL Regex MatchingNextRandomised Responses

Last updated 5 years ago

Was this helpful?

When working with an existing API it can be useful to pass some requests through to it for testing, while serving mock responses for others.

For instance, if an API is not yet fully implemented then testing progress can still be made for the calling application by mocking the parts not yet completed.

Additionally, proxying all but a selection of APIs enables testing of edge and failure cases that would be hard to replicate predictably in the target API.

How to configure proxy settings

You can configure proxy settings for each of your mock API. All you have to do is click the Configure proxy server icon and provide the the proxy url you want to forward your mock API request.

Once you are done with configuring your proxy settings, you can now enable Use API as Proxy settings to start proxing your call to the provided url.

Once a mock API is configured and enabled to serve a proxy response, all of the normal request matching rules apply, but instead of returning a saved response, the request is forwarded to the target url.

The endpoint of a request’s URL will be replaced by the proxy url i.e. if a request made to https://api.mocklets.com/mock12675/pets would result in a proxy request to https://your.server.com/pets.

Whenever a request is proxied, Mocklets adds 2 headers to the response with the details about the proxied request.

x-mocklets-proxy-url: https://your.server.com/pets
x-mocklets-type: proxy