无效的主机头mysql反应heroku

时间:2019-03-20 04:29:58

标签: reactjs express heroku

我正在尝试将mysql express react应用程序部署到heroku,但是我在部署的项目无效的主机头上收到一条消息,我在客户端包json中使用代理:

{
"name": "crud",
"version": "0.1.0",
"private": true,
"proxy": "http://localhost:5000/",
"dependencies": {
"axios": "^0.18.0",
"bootstrap": "^4.3.1",
"http-proxy-middleware": "^0.19.1",
"morgan": "^1.9.1",
"react": "^16.8.4",
"react-bootstrap": "^1.0.0-beta.5",
"react-bootstrap-modal": "^4.2.0",
"react-confirm-alert": "^2.3.0",
"react-dom": "^16.8.4",
"react-router-dom": "^4.4.0",
"react-scripts": "2.1.8"
},

我的server.js文件如下所示:

const express = require("express");
const path = require("path");
const cors = require('cors');
const bodyParser = require('body-parser');
const logger = require("morgan")
// Initialize Express
const app = express();

const PORT = process.env.PORT || 5000;
const db = require("./models");
//Middleware
app.use(express.urlencoded({ extended: true }));
app.use(express.json());
// Routes
const apiRoutes = require("./routes/API");
app.use("/api", apiRoutes);
// API
// app.use('/api', apiRoutes);
// app.use("/auth", authRoutes);
// app.use("/authorize", dashRoutes)

// Configure middleware
// Use morgan
app.use(logger("dev"));
// Use body parser
app.use(bodyParser.json());
// Use cors
app.use(cors());

// Connecting to DB

// Serve up static assets (usually on heroku)
// 


db.sequelize.sync({})

app.get("*", function(req, res) {
res.sendFile(path.join(__dirname, "./client/build/index.html"));
});

app.listen(PORT, function(){
    console.log(`APP listening on PORT ${PORT}`)
});

我尝试使用.env.production文件,但这似乎也不起作用, 有什么想法吗?

0 个答案:

没有答案