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

134
Visualizações
Query String missing when redirecting with expressjs

I have the following express js route which helps in redirecting to the given URL.

app.get("/", async (req, res) => {
  const url = req.query.url;
  res.redirect(url);
});

It's working fine. But the problem is, somehow the passed query strings is getting cut off for no reason.

Example:

This is what I'm actually passing.

http://localhost:3000/?url=https://google.com/?abc=123&def=456&aaa=098

After redirecting whatever after the first query string goes missing.

It's appearing like this.

https://google.com/?abc=123

Not sure why &def=456&aaa=098 goes missing.

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

0

Use the encodeURIComponent and decodeURIComponent functions.

For example:

app.get("/", async (req, res) => {
  const url = req.query.url;
  res.redirect(decodeURIComponent(url));
});

Note that the url parameter must be encoded in the actual URL.
Your URL should look something like this:

http://localhost:3000/?url=https://google.com/%3Fabc%3D123%26def%3D456%26aaa%3D098
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