NancyFX + CORS

Every once in a while you need to have access to a json api from another domain.

Thankfully there’s a mechanism to allow this. This Mechanism is called CORS

So before any JSON request is allowed a Options requst will be sent to the corresponding ressource and expects a „Access-Control-Allow-Origin“ header to be present.

There can be different values set for this which is explained in the linked article.

To enable this globally for a NancyFX Module you have to put the following code into it.

Hopefully this will help some folks out there

Kommentar verfassen