如何设置我的ReactJs应用程序以防止出现以下错误消息:
访问CORI策略已阻止从源“ https://api.mailgun.net/v3/sandbox89eb8f83cebd77263172e.mailgun.org/messages”获取“ http://localhost:3002”的访问:在飞行前响应中,Access-Control-Allow-Headers不允许请求标头字段授权。
onSubmitForm(e){
e.preventDefault();
//Mailgun
var api_key = 'API Key(//obviously won't show this)';
var domain = 'sandbox89eb814ff83bd77c0c7d263172e.mailgun.org';
var mailgun = require('mailgun-js')({apiKey: api_key, domain: domain});
var data = {
from: 'Excited User <me@samples.mailgun.org>',
to: 'test@something.org.au',
subject: 'Hello',
text: 'Testing some Mailgun awesomeness!',
};
mailgun.messages().send(data, function (error, body) {
console.log(body);
});
}