Handling CORS error

Cross-origin resource sharing (CORS) is a mechanism that allows restricted resources on a web page to be requested from another domain outside the domain from which the first resource was served.
While performing a CORS mechanism on Studio you might come across some CORS errors, restricting you from accessing resources from other domains.

Let’s take a use case:

Suppose the user wants to download an image via URL from some domain by using the Studio platform and the File Download on-screen action.
Let’s start from our basic mini-app layout. The text input control will take URL as input which will be shown in the image control and is to be downloaded on click of the button.

The download file action being used.

Now when we click on the action button, we receive an error due to CORS error. So, to fix this, we provide you a proxy URL through which can be used to achieve the same result.

For your convenience, here is the proxy URL with a sample image as the query string.

https://studio.dronahq.com/proxyUrl?imageUrl={url}

To use it, we will take the support of JS Code action:

Followed by the Download File action with the output of the JS Code as its bounded keyword.

Now, hit preview and click the download button again.