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

174
Visualizações
How to make ReactRouter ignore an URL?

I am hosting my React project on Apache and had to redirect requests using the .htaccess file. It's in React, but also uses vanilla javascript and HTML sites.

In production (npm start), here is how it worked:

If the site got certain tokens from Firebase, the page would get redirected to the site like this:

{HaveToken ? (
      
     <BrowserRouter>
       <Route exact path="/" render={() => {window.location.href="tv/indextv.html?m="+auth.currentUser.email+"&p="+othermail+"&t="+othertoken}} />
       
      </BrowserRouter>
    ):null}

If it did not, the return statement of the function would just go on, rendering other things. On the html/javascript site, with on click of a button, It would then get redirected to this same App.js project, with this line:

window.location.href = 'http://localhost/messages';

It would just run the App.js, and it worked perfectly, it wouldn't get rerouted again because it's no longer just "/".

Now that I built it, and added it to an Apache server, it works differently. For /messages, I get a 404 error, for... well, obvious reasons.

My question is, how can I fix this problem? I tried to do it by adding something like localhost?m=m so the location would be the same, but the URL is slightly different. Sadly, Route still thinks it's the same path. Is there any way I can make Route only render the other site if they did not get here by clicking a button on the other site? Or can I pass something from the other site that could make Route ignore that it's the same path?

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