Geting CORS error when trying to use communication-email package with Angular

Petko Bozhinov 1 Reputation point
2022-09-14T13:59:17.193+00:00

I've been facing some issues when trying to send an email using the @azure/communication-email package with Angular.
My scenario is as follows: I have a serverless client application written in Angular that should also send emails.
For that purpose, I wanted to use the @azure/communication-email service and followed the docs through. I configured my app in accordance with the topic but then upon calling the send-method, a CORS error was thrown, as one could see on the screenshot below.

241064-image.png

I've been doing exactly the same steps with the same package, with the same token and sender data in a Node application and the issue does not reproduce. I wanted to ask whether that is a bug with the newly introduced communication email functionality, or has something to do with the browser environment of the Angular app? If the package is meant to be used by a browserless environments only, is it described somewhere in more details, ever since I was unable to find so.

Regards,
Petko

Azure Communication Services
Azure Communication Services
An Azure communication platform for deploying applications across devices and platforms.
684 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Ryan Hill 25,981 Reputation points Microsoft Employee
    2022-09-19T13:42:11.17+00:00

    Hi @Petko Bozhinov ,

    Currently, the email service doesn't send CORS headers. This support is forthcoming in a future update but until then, this scenario probably won't work.

    The team, however, would like better understanding of the cross-origin request working on your NodeJS and Angular. Could be related to preflight (OPTIONS) request but please verify. Can you attach a screen recording or browser network trace from both app executions that I can pass along to the team?

    ---
    EDIT 20 November 2022 CORS header *Access-Control-Allow-Origin: * * has been set on email services public endpoints.

    1 person found this answer helpful.