Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

133
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!