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?