mailgun和angular2:请求标头字段预检响应中的Access-Control-Allow-Headers不允许授权

时间:2016-11-30 22:13:39

标签: angular cors mailgun

我正在尝试通过mailgun休息服务发送电子邮件,但我遇到了跨域问题。

我尝试过很多解决方案,添加标题。但没有任何效果。

直播演示(只需点击按钮即可重现错误): https://bitcash.herokuapp.com/#/dashboard

完整代码: https://github.com/Tyvain/bitcash

的src /应用/存储/进料/ feed.effects.ts

 requestHeaders.append("Authorization", "Basic " + this.mailgunApiKey);
 requestHeaders.append("Content-Type", "application/x-www-form-urlencoded");

 this.http.request(new Request({
          method: RequestMethod.Post,
          url: "https://api.mailgun.net/v3/sandbox41db17f981b345018e03f5b1dbc281fa.mailgun.org/messages",
          body: "from=" + action.payload.from
                + "&to=" + action.payload.to
                + "&subject=" + action.payload.subject
                + "&text=" + action.payload.text,
          headers: requestHeaders
      }))

也尝试了这个(不工作):

requestHeaders.append("Authorization", "Basic " + this.mailgunApiKey);
requestHeaders.append("Content-Type", "application/x-www-form-urlencoded");
requestHeaders.append("Access-Control-Allow-Origin", "*");
requestHeaders.append("Access-Control-Allow-Credentials", "true");
requestHeaders.append("Access-Control-Allow-Methods", "POST, GET, OPTIONS");

0 个答案:

没有答案