Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

428
Visualizações
Express.js unexpected 'GET' to '/json/version'

I'm new to Express, but I keep getting a 404 error because something is making a GET request to '/json/version'. It goes through the first app.use('/') and adds the session data, then it ignores the two routers, and then triggers the 404 error handling. Does anyone know where it could be coming from? It's holding up my project and I'm quite frustrated.

I found someone with the same issue here, but nothing has been very helpful (as far as I can tell). Most of this app is generated from express-generator, with only the session being added by me, but I can't find any documentation from express-session that says this is expected behavior. Below is my code.

// Package requirements
let createError = require('http-errors'),
    express = require('express'),
    session = require('express-session'),
    path = require('path'),
    cookieParser = require('cookie-parser'),
    logger = require('morgan');

// Local requirements
let indexRouter = require('./routes/index'),
    usersRouter = require('./routes/users');

// App definition
let app = express();

// View engine setup (EJS)
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');

// Session data
app.use(session({
    secret: 'Super Secret',
}));

app.use(logger('dev'));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));

app.use('/', (req, res, next) => {
    req.session.id = 1;
    next();
});
app.use('/', indexRouter);
app.use('/', usersRouter);

// Catch 404 and forward to error handler
app.use(function(req, res, next) {
  next(createError(404));
});

// Error handler
app.use(function(err, req, res) {
  // set locals, only providing error in development
  res.locals.message = err.message;
  res.locals.error = req.app.get('env') === 'development' ? err : {};

  // render the error page
  res.status(err.status || 500);
  res.render('error');
});

// Specifies Node.js port
app.listen(3000, function() {
  console.log('Listening on port 3000')
});

module.exports = app;

Thanks in advance!

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Was addressed in this issue.

Click "Configure" in chrome://inspect and remove port 3000

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda