Hello Suraj K M,
I see you're having some trouble accessing Azure Digital Twin endpoints directly from your React app due to CORS issues. Unfortunately, Azure Digital Twins doesn’t currently support CORS, which is why you're experiencing this blockage when trying to connect from your frontend.
Since you mentioned that you've created a Node.js app and are able to obtain the Auth Token and fetch API responses from ADT endpoints, deploying this backend alongside your React app on Azure is a solid plan. You can have your React application interact with your Node.js backend, which then communicates with the Azure Digital Twins service.
Here are a couple of ways you might want to proceed:
- Build a Node.js Proxy: Use your Node.js application as a middleware to handle requests to Azure Digital Twins. This allows you to:
- Fetch the data from Azure Digital Twins in your Node.js app.
- Send that data back to your React app, thus avoiding CORS issues.
- Azure Functions: If you're looking for a lightweight serverless option, consider using Azure Functions. You can create an HTTP-triggered function that acts as a proxy to your Azure Digital Twins requests. Azure Functions can have CORS enabled, allowing your React app to communicate without issues.
- API Management: Implement Azure API Management to handle requests and integrate CORS policies. This method can manage and secure your backend services while providing a unified endpoint for your React application.
Regarding potential blockers after deployment:
- Ensure that your Node.js app is set up correctly to handle the authentication flow and token management for the Azure Digital Twins API.
- Double-check that the permissions for your Microsoft Entra app registration are correctly configured with the appropriate roles to access Digital Twins.
- Make sure that any dependencies required for your Node.js app are included and correctly configured in your Azure environment.
Hope this helps!
Thank you!