Automatic handling of preflight OPTIONS requests

Front and API are not on the same domain? Handle preflight requests automatically with Mockoon.

Get Mockoon latest version and start mocking!


When mocking, chances are front application and mocked API won’t be on the same domain, thus triggering browsers OPTIONS preflight requests.
Failing to answer to these requests may prevent your application from working. Luckily, Mockoon can handle this for you:
  1. Open the environment settings by clicking on the cog in the upper right corner:
Open environment settings
  1. Enable CORS option, ensure that blue crossing arrows are displayed next to the environment name which indicates that CORS option has been successfully activated.
Enable CORS mode

You may need to restart the environment for the changes to take effect.

Starting from now Mockoon will automatically answer with a 200 HTTP status code to all preflight OPTIONS requests. The following headers will also be added to the response:

Access-Control-Allow-Origin: *
Access-Control-Allow-Headers: Content-Type, Origin, Accept, Authorization, Content-Length, X-Requested-With

Mockoon won’t send any CORS header if you define a route with the OPTIONS method in your environment (i.e. OPTIONS /my-route), leaving you in full control of the headers you want to add.

Join Mockoon's mailing list to receive latest updates