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

136
Visualizações
getting error after route parameters added to route handler

When I add the ':username' route param to my GET path (in code below), I start running into this error:

Expected a JavaScript module script but the server responded with a MIME type of "text/html".

My dashboarduser.js is defined in my dashboarduser.ejs I have attempted to use the '.mjs' extension as per the MDN doc recommendation, as well as setting the headers to ("Content-Type", text/html) & also text/javascript, but to no remedy.

Here are my two route handlers that I use:

app.get(`/dashboarduser/:username`, isLoggedIn, (req, res) => {
    res.setHeader("Content-Type", "text/html")
    res.render('dashboarduser', {user: req.user.username})
    console.log("req.user: " + req.user.username);
})

app.post('/login', passport.authenticate('local', {
    // successRedirect: `/dashboarduser`,
    failureRedirect: '/login',
    failureFlash: true,
}), (req, res) => {
    res.redirect('/dashboarduser/' + req.user.username)
});

When a user logs in, they are taken to their dashboard with their req.params. E.g. website.com/dashboarduser/johndoe, but there is the lingering error in the console. I am running a local strategy via passport-local, and using passport local mongoose for a local DB. Ultimately I want users to be able to have their own events they set up, and I want them to be able to easily share a URL to invite others. Are these route params necessary or will the local storage take care of this?

Thanks for reading~

about 4 years ago · Juan Pablo Isaza
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