Sending a template with markup and CSS

Once the markup is generated, we first check if there was a redirect rendered in the component to be sent in the markup. If there was no redirect, then we generate the CSS string from the sheetsRegistry, and in the response send the template back with the markup and CSS injected. 

mern-skeleton/server/express.js:

if (context.url) {   return res.redirect(303, context.url)}const css = sheetsRegistry.toString()res.status(200).send(Template({   markup: markup,   css: css}))

An example of a case where redirect is rendered in the component is when trying to access a PrivateRoute via server-side render. As the server side cannot access the auth token from client-side sessionStorage, the redirect in the PrivateRoute ...

Get Full-Stack React Projects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.