Serving static html page from one app to react one page using router
I have one single page app and I am looking at a static html service, SEO friendly landing page in a scenario where the user is not logged in. I would like one page to be crawled by all search engines (the rest of the site is password protected for SEO, it doesn't matter. I am using a reactive router and cannot find a way in the application to redirect the user to a static html file (which will therefore be served on the side server) if the app detects they are not logged in. Any suggestions? Thanks!
source to share
This is what you could do in your router on the server. You cannot do this in your React app, because it defeats the goal of using JS-less content (since you will be using JS to deliver "static" content).
If you don't already have a server with a router, this will take some time. But once you've done that, a simple route check is sufficient.
// in hapijs, for example:
handler(request, reply) {
if (isAuthenticated(request)) {
reply.view('dashboard')
} else {
reply.view('static_page')
}
}
source to share