我正在尝试使用 SendGrid v3 发送电子邮件...在开发模式下,当我从 localhost 发送消息并且我的 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')
}
感谢您的反馈