【发布时间】:2016-12-07 21:44:52
【问题描述】:
我正在尝试在 ionic 应用程序中设置 Mailgun mail service。这是代码: 控制器:
$http({
"method": "POST",
"url": "https://api.mailgun.net/v3/" + mailgunUrl + "/messages",
//"crossDomain": "true",
"headers": {
"Access-Control-Allow-Origin": "*",//"http://localhost:8100",
"Access-Control-Allow-Headers": "content-type, accept",
//"Access-Control-Allow-Credentials": "true",
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE",
"Content-Type": "application/x-www-form-urlencoded",
'Authorization' : 'Basic '+ mailgunApiKey
//"Authorization": "Basic " + mailgunApiKey//$base64.encode('api:key-'+mailgunApiKey)
},
data: "from=" + "no-reply@ineevent.com" + "&to=" + $scope.datapopup.mail + "&subject=" + "Guestlist" + "&text="
config.xml
<content src="main.html"/>
<access origin="*"/>
<plugin name="cordova-plugin-whitelist" version="1"/>
<plugin name="cordova-plugin-crop" spec="~0.1.0"/>
<allow-navigation href="*" />
<allow-intent href="*"/>
<allow-intent href="http://*/*"/>
<allow-intent href="https://*/*"/>
<allow-intent href="tel:*"/>
<allow-intent href="sms:*"/>
<allow-intent href="mailto:*"/>
<allow-intent href="geo:*"/>
我收到 status '0' error 并且日志显示 CORS(跨域请求)在缺少 access-control-allow-headers 的情况下不允许(从法语翻译)。
Chrome 的另一个错误是'Request header field Access-Control-Allow-Origin is not allowed by Access-Control-Allow-Headers in preflight response.'。
我也尝试从 android 设备但无法正常工作。有什么想法吗?
【问题讨论】:
标签: ionic-framework cors mailgun