我有一个NextJS,它也向Next中的API路由发送请求。API使用Gmails STMP发送电子邮件。它在localhost上工作得很好,但在AWS amplify上,它给了我这个错误:
[Error: 140058109941696:error:1408F10B:SSL routines:ssl3_get_record:wrong version number:../deps/openssl/openssl/ssl/record/ssl3_record.c:331:
2023-04-25T10:58:07.739-06:00 ] {
2023-04-25T10:58:07.739-06:00 library: 'SSL routines',
2023-04-25T10:58:07.739-06:00 function: 'ssl3_get_record',
2023-04-25T10:58:07.739-06:00 reason: 'wrong version number',
2023-04-25T10:58:07.739-06:00 code: 'ESOCKET',
2023-04-25T10:58:07.739-06:00 command: 'CONN'
2023-04-25T10:58:07.739-06:00 }
这是我为STMP使用的配置:
SMTP_HOST=smtp.gmail.com
SMTP_PORT=465
这是我从Web应用程序本身发出的API调用:
await axios.post(
"/api/email",
{
formData: {
//...
},
},
{
headers: {
"Content-Type": "application/json",
},
onUploadProgress: (progressEvent) => {
console.log(
"Upload Progress: " +
Math.round(
(progressEvent.loaded / (progressEvent.total ?? 1)) * 100
) +
"%"
);
},
}
);
1条答案
按热度按时间sycxhyv71#
我最终使用Next在next.config中的重写创建了一个代理,以从API调用中删除httpS,因为Amplify试图强制执行它,现在它可以工作了。