So I know that the question has allready been asked before. And I actually found the solution for the problem. But that's not exactly the solution I want. I'll explain first my problem.
I am using React router and express. When we first visit the site ( A GET to the root path '/'), the 'index.html' file is serverd(with the react code that goes with it). But when i am in sub path, say 'https://example.com/my-sub-path', and then refresh I get 'Cannot GET/my-sub-path'. So I fixed this problem by adding this code:
app.get('*',(inRequest:Request, inResponse:Response)=>{
inResponse.status(300).redirect('/');
});
Before this one:
app.get('/',(inRequest:Request, inResponse:Response)=>{
inResponse.status(200).sendFile(path.join(__dirname,'../../client/dist/'));
});
Which redirects me to the HOME view (the root path) whenever I refresh.
I am on path 'https://example.com/my-sub-path' (at this point everything's fine)
And then I refersh THIS ROOT and my navigator is refreshed yet I'm still in the same view as earlier (I wouldn't be redirected to the root).
Any one can answer me ? I really don't know where to start :)
Oh! For example, I've seen lots of sites that are SPAs, but when you refresh you always have the same page, despite the url. For example google mui site