简体   繁体   中英

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?");} />

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM