mockfly logo

Switch Between Mock API Server and Real API

You can use Mockfly as a mock API server for your application, but you might also want it to act as aproxy for your real API. This is useful during development when you have some endpoints already implemented in a real API and others that are not yet available. This way, you can continue pointing your app to Mockfly and decide which endpoints should go through to the real API and which ones should not. This makes development easier, and you don’t have to worry about managing multiple environment variables while developing (we do not recommend using this approach in production). You can configure this from the project settings modal, which you can access from the project list or from within the project itself in the sidebar menu.

Mockfly project config proxy

Before explaining how to use Mockfly as a proxy, it is important to understand the different configurations available in Mockfly. There are two levels of configuration: project-level and endpoint-level. At the project level, you can enable or disable the proxy and specify the URL of the real API that Mockfly will use. Then, at the endpoint level, there are three possible settings you will find in the “Config” tab:

  • Use proxy: If enabled, Mockfly will use the real API URL for this endpoint even if the proxy is disabled at the project level.
  • Use mock: If enabled, Mockfly will return the mocked response for this endpoint even if the proxy is enabled at the project level.
  • Use inherited settings from project: This will use the project’s configuration. This is the default setting for all endpoints.
Mockfly endpoint config proxyCreate a project