HTTP request to Teams webhook from a website is blocked by CORS

Givan, Claudia 0 Reputation points
2024-05-07T08:06:59.25+00:00

Hello Microsoft Teams Support,

I have developed a website using Hugo and am attempting to send messages to a Microsoft Teams channel via a webhook. However, I'm encountering a CORS (Cross-Origin Resource Sharing) issue that is blocking the HTTP request.

Here is the code snippet I'm using:

const resp = await fetch(teamsWebhookURL, {
    method: "POST",
    body: JSON.stringify({ text: message }),
    headers: {
      "Content-Type": "application/json",
    },
});

Could you please provide guidance on how to configure CORS to allow these requests, or is there a way to bypass the CORS policy in this context?

Thank you for your assistance.

Microsoft Teams | Development
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.