Insights Hub CORS error calling backend API from frontend app

2024-09-09T12:45:19.000+0530
Developer Tools Applications

Summary

This article provides a solution to handle the Cross-Origin Resource Sharing (CORS) error that occurs when calling a backend API from a frontend application due to requests originating from different domains.


Details

When calling a backend API from a frontend application, a CORS error is common if the frontend app and the backend API are hosted on different domains or origins. Browsers implement this policy for security purposes, disallowing such cross-origin requests unless the server permits them.

 

To resolve this, you can use the following URL structure for your API calls, which should bypass the CORS issue if configured correctly:

https://{userTenant}-{AppName}-{HostTenant}.eu1.mindsphere.io/api/{API_AppName}/v1/{Endpoints}

This URL pattern includes:

  • userTenant: The tenant making the API request.
  • AppName: The name of the application making the request.
  • HostTenant: The host tenant of the backend API.
  • API_AppName: The specific API application name.
  • Endpoints: The desired API endpoints you are trying to access.

KB Article ID# KB000134378_EN_US

Contents

SummaryDetails

Associated Components

Developer Cockpit