我在Heroku上的节点应用出现H10错误。在我将Google Analytics(分析)添加到我的EJS文件之前,它一直运行良好。我的环境端口设置很好,我认为唯一可能的另一件事是我与MLab上的MongoDB数据库的连接...
这是应用程序文件:
var express = require('express'),
app = express(),
router = express.Router(),
ejs = require('ejs'),
bodyParser = require('body-parser'),
passport = require('passport'),
LocalStrategy = require('passport-local'),
mongoose = require('mongoose'),
flash = require('connect-flash'),
methodOverride = require('method-override'),
Post = require('./models/post'),
helmet = require('helmet'),
Comment = require("./models/comment"),
Email = require("./ignore/email"),
Raph = require("./ignore/raphuser"),
User = require('./models/user'),
nodemailer = require('nodemailer');
postRoutes = require('./routes/posts');
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: true}));
app.use(methodOverride("_method"));
app.set('view engine', 'ejs');
app.use(passport.initialize());
app.use(passport.session());
passport.use(new LocalStrategy(User.authenticate()));
passport.serializeUser(User.serializeUser());
passport.deserializeUser(User.deserializeUser());
app.use('/api/posts', postRoutes);
app.use(helmet());
app.use(flash());
app.use(express.static(__dirname + '/views'));
app.use(express.static(__dirname + '/public'));
// then my routes
app.listen(process.env.PORT || 5000);
还有我与MLab的联系:
var mongoose = require('mongoose');
mongoose.set('debug', true);
mongoose.connect("mongodb://myusername:mypassword@ds147390.mlab.com:47390/dbname");
mongoose.Promise = Promise;
module.exports.Post = require('./ post');