Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
);
try {
// Recurse the component tree and prefetch all Apollo data queries to
// populate the Apollo Client Redux store. This allows an instant
// server side render.
// See: http://dev.apollodata.com/react/server-side-rendering.html#getDataFromTree
await getDataFromTree(appComponent);
} catch (error) {
// Prevent Apollo Client GraphQL errors from crashing SSR.
// Handle them in components via the data.error prop:
// http://dev.apollodata.com/react/api-queries.html#graphql-query-data-error
}
const markup = renderToString(sheet.collectStyles(appComponent));
const moduleIds = flushModuleIds();
const helmet = Helmet.renderStatic();
const { js, styles, cssHash } = await flushChunks(clientStats, {
moduleIds,
before: ['bootstrap', 'vendor'],
after: ['main'],
outputPath,
rootDir: path.resolve(appRoot.get()),
});
const preloadedState = store.getState();
preloadedState.apollo = apolloClient.getInitialState();
const styleTags = sheet.getStyleTags();
if (routerContext.url) {
res.status(301).setHeader('Location', routerContext.url);
export const flushedAssets = (clientStats, outputPath, production) => {
const moduleIds = flushModuleIds()
const chunkNames = flushChunkNames()
return {
moduleIds,
chunkNames,
...flushChunks(clientStats, {
chunkNames,
before: production ? ["bootstrap", "vendor"] : ["bootstrap"],
after: ["main"],
outputPath
})
}
}