我的应用程序运行正常,但是每当我尝试将其部署到Heroku时,都会不断出现此错误。
index.js:
const express = require('express');
const mongoose = require('mongoose');
const cookieSession = require('cookie-session');
const passport = require('passport');
const bodyParser = require('body-parser');
const keys = require('./config/keys');
require('./models/User');
require('./models/Asset');
require('./models/Episode');
require('./config/passportConfig');
mongoose.connect(keys.mongoURI, { useNewUrlParser: true });
const app = express();
app.use(bodyParser.json());
app.use(
cookieSession({
maxAge: 30 * 24 * 60 * 60 * 1000,
keys: [keys.cookieKey]
})
);
app.use(passport.initialize());
app.use(passport.session());
require('./routes/authRoutes')(app);
require('./routes/assetsRoutes')(app);
if(process.env.NODE_ENV === 'production') {
app.use(express.static('client/build'));
const path = require('path');
app.get('*', (req, res) => {
const index = path.join(__dirname, 'client', 'build', 'index.html');
res.sendFile(index);
});
}
const PORT = process.env.PORT || 5000;
app.listen(PORT, () => {
console.log(`server is up at port ${PORT}.`)
});
index.html实际上在那里,但是Heroku似乎从未找到它
请忽略这只是填充符,因为StackOverflow不会让我 发布一个没有详细信息的问题,但是我没有太多要添加的信息。 :)