Requestly
FeaturesHTTP InterceptorPricingRequestly vs PostmanBlogDocsDownload

Home / Blog / Guides

Switch API Endpoints Between Environments Easily

Web developers often want to test the local changes directly on production websites — be it for debugging a production bug or for testing local changes before shipping code to production. Tools like Source Maps or Local Overrides don’t often work for this setup. With Requestly, you can map your production endpoints to local endpoints on your machine in less than a minute.

Use Requestly to switch production API endpoint to local

Suppose you have the production APIs on domain.com, you can switch it to **localhost:4001** using Requestly’s Replace rule. This will enable you to test your local changes on production.

  1. Install the Requestly browser extension and click on New Rule in the Top-Right.

Use Requestly to switch production API endpoint to local screenshot

  1. Next, Select the Replace String Rule from the list of rules. This should navigate you to the rule editor.

  2. Define for which requests you want the modifications to be made.

    eg: If you want to replace domain.com with localhost:4001

    Use Requestly to switch production API endpoint to local screenshot

  3. Save the rule and test if the endpoint has been switched on the configured site.

Possible CORS issue

Most production systems have very strict CORS policies, only allowing the production site to access the resources served. It is likely that CORS error will occur if you switch endpoints.

If you face any CORS issue, then you need the create a headers rule bypass the CORS headers. Please find more details on how to solve CORS errors here.

Test any API request visually: import a cURL command or build from scratch in Requestly, the free API client for developers.

Download →