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

152
Visualizações
Why the script file is on my req.params how to get rid of that?

I'm trying to extract the :rid to my req.params but I get two values the rid and the script file.

here is the console.log picture

console.log picture

my route code

router.get('/room/:rid', async (req, res) => {
  console.log(req.params);
  res.render('room', { roomId: req.params.rid });
});
 

my dashboard code to redirect the user to room.ejs when the user click

 function goto(){
    var roomID = document.getElementById("roomID").value;

    window.location.replace(`/room/${roomID}`);

 }

and my room.ejs head

<script src="this.js" defer></script>
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Change this:

<script src="this.js" defer></script>

to this:

<script src="/this.js" defer></script>

Assuming that script was present in a web page called /room, then when the browser sees a request for "this.js", it will combine that with the path of the page and ask for /room/this.js which will hit your /room/:rid route which is not what you want.

Generally, you always want script file paths to be absolute paths (start with a /) so they are fixed and not dependent upon the path of the page they are contained in .

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