'React-Router: Force reload in browser

We have a monolithic react SPA deployed with AWS Cloudfront. We are trying out microsite architecture where each route/path in the react app will be built and deployed as a standalone app. To achieve this we have configured path-based behaviors in Cloudfront to route the request to the respective origin which works fine.

Due to its SPA nature, all the routes defined in the monolithic react app tries to load pages without sending a request to the server. This is causing issues because we want a few routes to be loaded from the server so that CloudFront can route the requests properly.

How can we force react-router to load a specific route from the server?

<Route exact path="/example" render={()=>console.log("load from server?");} />



Solution 1:[1]

Well, react-router routing happens at client level, so you don't have to use it to get server-rendered pages.

What you need is just an a tag, like

<a href="/example" alt="A page you want to load">Label</a>

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Emanuele Scarabattoli