I cannot connect to my local node.js/express server. I get the error ERR_EMPTY_RESPONSE after ~2 minutes of loading. I'm running the server on the same machine that i am trying to connect from.
Here's my code:
const express = require('express');
const fs = require('fs');
const cookieParser = require('cookie-parser');
const pug = require('pug');
const config = require('./helpers/config.js');
const app = express();
app.engine('pug', require('pug').__express);
app.set('views', './views')
app.set('view engine', 'pug');
app.use(express.static(__dirname + '/public'));
app.use(require('./middlewares/auth'));
app.use(function (req, res, next) {
console.log("Error!");
res.status(404);
if (req.accepts('html')) {
res.render("404", {url: req.url})
res.end()
return
}else if (req.accepts('json')) {
res.send({error: 404, message: "Not found!"})
res.end()
return
}
res.type('txt').send('404 Not found!')
res.end()
})
app.get('/', function (req, res) {
console.log("root");
res.render('index', {message: "Hello World!"})
res.end()
})
app.listen(3000, function() {
console.log('Listening on port 3000...');
})
via Theo Sandell
No comments:
Post a Comment