CORS issue with using https block to send REST API request to 3rd party api

Hello, im currently trying to send a request to zendesk using rest api, but it keeps on throwing CORS issue which im not that much familiar with this issue yet. Any help would be appreciated.

  • screenshots attached + error
    Thanks

Hi @Lerwin_Tan1 ,

The CORS (Cross-Origin Resource Sharing) error you’re experiencing is a common issue when making requests directly from the browser (such as with JavaScript running in Backendless UI Builder) to third-party services like Zendesk.

What’s causing this?

Zendesk’s REST API does not include your application’s origin in its allowed CORS headers. This means browsers will block those direct requests as a security measure. This is a limitation imposed by the Zendesk API (and many others), not by Backendless.

Instead of calling Zendesk’s API directly from the browser, you can create a custom API service using Backendless Cloud Code (Logic/Business Logic). This service will make the Zendesk API call from the server (no CORS restrictions) and then return the result to your UI.

Steps:

  1. Create a Backendless API Service via JavaScript or Codeless.
  2. In your service, use fetch or Backendless SDK to send the HTTP request to Zendesk.
  3. Call your API service from your frontend (UI Builder). The browser is only communicating with Backendless, which ALWAYS allows CORS for your domain.

Documentation:

Why you can’t bypass CORS in the browser:
Browsers enforce the CORS specification for security. This cannot be bypassed in frontend code. Only server-side code (like Business Logic in Backendless) can freely communicate with third-party APIs without CORS headaches.

Regards, Andriy

Hello, thanks for taking the time to explain the problem.
The links attached aren’t working.
Also if we use this backend services, will it count to our API calls provision?

@Lerwin_Tan1 ,

Yes, they will be counted as additional API call.

Sorry for the broken links. Here are correct ones:
CloudCode with JS
CloudCode with Codeless

Regards, Andriy