我正在使用sendgrid通过联系表单发送电子邮件。它可以在具有端口3001的localhost中正常运行。如何在具有端口值的访存中使用我的域。有人可以帮忙吗?
这是单击按钮的代码
const { email } = this.state
fetch(`http://domain.in:3001/contactus/send-email?recipient=${email.recipient}&sender=${email.sender}&topic=${email.subject}&text=${email.text}`)
.catch(err => {
console.log("error ", err);
})
this.setState({ email: { ...email, subject: '', sender: '', text: '' } })
}````
--------> this is on server.js <-----------
const express = require('express');
const cors = require('cors');
const sgMail = require('@sendgrid/mail');
const app = express()
const port = process.env.PORT || 3001;
sgMail.setApiKey('*******************')
app.use(cors());
app.get('/', (req, res) => {
res.send('Welcome to the Sendgrid Email server');
})
app.get('/contactus/send-email', (req, res) => {
const { recipient, sender, topic, text } = req.query
console.log("came ");
const msg = {
to: recipient,
from: sender,
subject: topic,
text: text
}
sgMail.send(msg).then((msg) => {
console.log(text);
})
})
app.listen(port, () => console.log(`Listening on port ${port}`));