繁体   English   中英

Vue.js 使用 SendGrid v3 发送 email:不允许访问

[英]Vue.js sending email with SendGrid v3 : not allowed access

我正在尝试使用 SendGrid v3 发送电子邮件...在开发模式下,当我从本地主机发送消息并且我的 SendGrid 帐户已为我的生产域 www.mydomain.com 设置时,我收到一条错误消息:未授权..我能够了解...

Failed to load https://api.sendgrid.com/v3/mail/send: Response to preflight 
request doesn't pass access control check: The 'Access-Control-Allow-Origin' header 
has a value '://sendgrid.api-docs.io' that is not equal to the supplied origin. 
Origin '://localhost:8080' is therefore not allowed access. Have the server send 
the header with a valid value, or, if an opaque response serves your needs, 
set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

有没有办法在开发模式下使用 SendGrid? 还是我应该绕过发送邮件?

    if (process.env.NODE_ENV === 'production) {
      this.sendContactEmail()
    } else {
      console.log('CANNOT SEND MESSAGE IN DEVELOPMENT ENVIRONMENT')
    }

感谢您的反馈

您不能在基于客户端的应用程序中使用 SendGrid。 这可能是它失败的原因。 您需要一个后端服务器/服务,或者如您所说,您可以使用 firebase 的无服务器功能来触发 API 调用

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM