在构建MERN应用程序并部署到cPanel Live域后,SendGrid无法投入生产

时间:2020-02-25 01:33:47

标签: cpanel sendgrid mern

好奇是否有人可以帮助解释为什么我的代码(下面是重要的代码片段)发送站点访问者填写的表单详细信息(通过我的MERN应用程序中的SendGrid)在开发模式下执行bookPartyRoom()函数时起作用的原因,但是建立纱线并将其部署到带有cPanel的生产站点后,无法发送电子邮件。在生产环境中尝试使用此功能时,会收到404错误:

//Main.js

bookPartyRoom = (event) => {
  axios.post('/bookPrivateRoom', {
    partyName: this.refs.name.value,
    partyDate: this.state.startDate,
    partyPhone: this.refs.phone.value,
    partyRoom: this.state.optionState,
    partyComments: this.refs.comments.value,
    partyEmail: this.refs.email.value,
    partyStart: this.state.startTime,
    partyEnd: this.state.endTime
}).then (
  document.getElementById("party-room-sidebar").style.height = "0px",
  alert("Thank you, " + this.refs.name.value.split(' ')[0] + "!  Angelo will reach out shortly to confirm your reservation & to take down your order for food and drink for the upcoming event.  *(Payment expected upon conclusion of party)"),
  this.refs.name.value = "",
  this.refs.phone.value = "",
  this.refs.email.value = "",
  this.refs.comments.value = "",
  this.setState({ 
    startDate: new Date(),
    startTime: moment(),
    endTime: moment()})
  ).catch(function (error) {
  console.log(error);
})}};

//config.json

{
    "development": {
      "username": "root",
      "password": "N/A",
      "database": "***_db",
      "host": "127.0.0.1",
      "port": 3306,
      "dialect": "mysql"
    },
    "test": {
      "use_env_variable": "JAWSDB_URL",
      "dialect": "mysql"
    },
    "production": {
      "username": "root",
      "password": "N/A",
      "database": "***_db",
      "host": "127.0.0.1",
      "port": 3306,
      "dialect": "mysql"
    }
 }

//package.json

{
  "name": "angelospizza",
  "version": "1.0.0",
  "engines": {
    "node": "12.x"
  },
  "description": "Mern Demo",
  "main": "server.js",
  "scripts": {
    "start": "if-env NODE_ENV=production && npm run start:prod || npm run start:dev",
    "start:prod": "node server.js",
    "start:dev": "concurrently \"nodemon --ignore 'client/*'\" \"npm run client\"",
    "client": "cd client && npm run start",
    "install": "cd client && yarn install",
    "build": "cd client && yarn install && npm run build"
  },

0 个答案:

没有答案