I’m trying to add a button that will send discord notification on click.
Here is my index.jsx
import React from 'react';
import ForgeReconciler, { Text,Button, useProductContext } from '@forge/react';
import { requestJira } from '@forge/bridge';
import api from "@forge/api";
const webhookURL = 'https://discord.com/api/webhooks/1201455081163615764/VEIy7tD63C2ZQ41131Rno8737qEN63xkVhG_698gAYe0YQRr4K-Mk_RPEXl3x_3hqIT4oA';
const App = () => {
const context = useProductContext();
const sendDiscordNotification = async () => {
try {
// Define the webhook URL
// Create the payload for the Discord webhook
const payload = {
content: 'Hello from Forge!',
};
// Send the POST request to the Discord webhook URL
await api.fetch(webhookURL, {
method: 'POST',
body: JSON.stringify(payload),
headers: {
'Content-Type': 'application/json',
},
});
console.log('Discord notification sent successfully');
} catch (error) {
console.error('Error sending Discord notification:', error);
}
};
React.useEffect(() => {
if (context) {
sendDiscordNotification();
}
}, [context]);
// render the value of `comments` variable
return (
<>
<Button onClick={sendDiscordNotification}>Send Zeuz Notification</Button>
</>
);
};
ForgeReconciler.render(
<React.StrictMode>
<App />
</React.StrictMode>
);
And here is my manifest.yml
modules:
jira:issuePanel:
- key: hello-world-hello-world-issue-panel
resource: main
resolver:
function: resolver
render: native
title: Testing App
icon: https://developer.atlassian.com/platform/forge/images/icons/issue-panel-icon.svg
function:
- key: resolver
handler: index.handler
resources:
- key: main
path: src/frontend/index.jsx
app:
id: ari:cloud:ecosystem::app/bg6xxxxxxxxxxxxxxxxxxxx6
permissions:
scopes:
- read:jira-work
external:
fetch:
backend:
- 'https://discord.com'
But When I click on it, i’m getting
Refused to connect to 'https://discord.com/api/webhooks/xxxxxx/xxxxxxxxx-xxxxx' because it violates the document's Content Security Policy.
~```
Can anyone please help me out?