-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CORS issues #14
Comments
I tried replacing your function sendToWebhook(message, msgText, hookEmbed, hook, img){
// To conform to the 'simple requests' to avoid triggering CORS,
// https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS#simple_requests
// which is no longer supported by browsers (servers only) or discord's API
// with the move to discord.com, we send multipart/form-data
// Discord supports passing a stringified JSON body as a form value as payload_json instead:
// https://discord.com/developers/docs/resources/webhook#execute-webhook
var request = new XMLHttpRequest();
request.open("POST", hook);
request.setRequestHeader('Content-type', 'multipart/form-data');
var params = {
username: message.alias,
// avatar_url: encodeURI(img),
content: msgText,
// embeds: hookEmbed
}
formData = new FormData();
formData.append("payload_json", JSON.stringify(params))
request.send(formData);
} But even that was still giving CORS errors. I think discord have just blocked browsers from accessing even their webhook APIs, which makes me sad, and renders this plugin broken, unless you're willing to override CORS security in your browser :( |
I found this https://chriscarey.com/blog/2014/06/13/apache-proxy-with-cors-headers/ but I didn't have much luck getting it to work for me. I've given up for now :( |
I got it working! Note there are two sections in the config:
|
I get this:
when attempting to connect the Discord Webhook to my Foundry server running on HTTPS. Googling, it looks like you need to send the Access-Control-Allow-Origin in both the OPTIONS and the POST request: https://stackoverflow.com/questions/63586021/discord-webhook-access-control-allow-origin
The text was updated successfully, but these errors were encountered: