I try to post a slack message via the fetch API in a browser:
fetch(\'https://hooks.slack.com/services/xxx/xxx/xx\', {
method: \'post\',
headers: {
\
I am using axios
and had similar issue. What worked for me is setting Content-Type
header to application/x-www-form-urlencoded
. found it in this thread: https://github.com/axios/axios/issues/475
It appears that this triggers "simple request" and therefore avoids triggering CORS preflight.
https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS#Simple_requests
HTH.