1

I am using azure communication services in my react app to send email.

But It is giving CORS error

But when running this code, I m getting this error.

Access to XMLHttpRequest at 'https://************************/emails:send?' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

In Azure docs, they have given the code in Node.js.

Since Iam using that code in react and accessing from front end, is it showing CORS error?

How to solve this issue?

1 Answers1

1

As you can see in the SDKs and REST APIs docs, ACS Email library is meant to be used in a trusted service environment. This is because there is no reasonable way to protect your connection string in the browser.

In your case, building a Node.js backend and letting your React app talk to it would be a good and preferred solution.

rocky
  • 7,506
  • 3
  • 33
  • 48